Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Parse XML returns the CDATA actual tag as string

Reply
 
Old 12-08-2008   #1 (permalink)
Gabriela


 
 

Parse XML returns the CDATA actual tag as string

Hi,
I have an XML like the one below received as POST parameter.

<set_info>
<pages save_set="new">
<page url="http://www.fueleconomy.gov/feg/bestworstEPAtrucks.htm">
<title>![CDATA[Most and Least Fuel Efficient Trucks]]</title>
<description>![CDATA[Most and Least Fuel Efficient Trucks]]</
description>
</page>
</pages>
</set_info>

When I try to parse it (see code below), the title and descriptions
values are returned with the word ![CDATA[...]]. Should the DOM parser
ignore it??


Set oPageNodes = xmlDoc.SelectNodes("set_info//pages//page")
for each oPage in oPageNodes

set oTitle = oPage.SelectSingleNode("title")
page_title = HTMLDecode(oTitle.firstchild.data)
set oDesc = oPage.SelectSingleNode("description")
page_desc = HTMLDecode(oDesc.firstchild.data)
next

Printing page_title returns
![CDATA[Most and Least Fuel Efficient Trucks]]
instead of
Most and Least Fuel Efficient Trucks

What am I doing wrong?
Thanks,
Gabi!

My System SpecsSystem Spec
Old 12-09-2008   #2 (permalink)
ekkehard.horner


 
 

Re: Parse XML returns the CDATA actual tag as string

Gabriela schrieb:
Quote:

> Hi,
> I have an XML like the one below received as POST parameter.
>
> <set_info>
> <pages save_set="new">
> <page url="http://www.fueleconomy.gov/feg/bestworstEPAtrucks.htm">
> <title>![CDATA[Most and Least Fuel Efficient Trucks]]</title>
CDATA is a node/element - so
<title><![CDATA[Most and Least Fuel Efficient Trucks]]></title>

[...]
My System SpecsSystem Spec
Old 12-22-2008   #3 (permalink)
Gabriela


 
 

Re: Parse XML returns the CDATA actual tag as string

On Dec 9, 10:11 am, "ekkehard.horner" <ekkehard.hor...@xxxxxx>
wrote:
Quote:

> Gabriela schrieb:> Hi,
Quote:

> > I have an XML like the one below received as POST parameter.
>
Quote:

> > <set_info>
> > <pages save_set="new">
> > <page url="http://www.fueleconomy.gov/feg/bestworstEPAtrucks.htm">
> > <title>![CDATA[Most and Least Fuel Efficient Trucks]]</title>
>
> CDATA is a node/element - so
> <title><![CDATA[Most and Least Fuel Efficient Trucks]]></title>
>
> [...]
Isn't it just the schema I've written above?
<set_info>
<pages save_set="new">
<page url="http://www.fueleconomy.gov/feg/
bestworstEPAtrucks.htm">
<title>![CDATA[Most and Least Fuel Efficient
Trucks]]</title>
<description>![CDATA[Most and Least Fuel
Efficient Trucks]]</
description>
</page>
</pages>
</set_info>

Thanks, Gabi.
My System SpecsSystem Spec
Old 12-26-2008   #4 (permalink)
ekkehard.horner


 
 

Re: Parse XML returns the CDATA actual tag as string

Gabriela schrieb:
Quote:

> On Dec 9, 10:11 am, "ekkehard.horner" <ekkehard.hor...@xxxxxx>
> wrote:
Quote:

>> Gabriela schrieb:> Hi,
[...]
Quote:

> Isn't it just the schema I've written above?
No
compare
Quote:
Quote:

>> <title><![CDATA[Most and Least Fuel Efficient Trucks]]></title>
to
Quote:

> <title>![CDATA[Most and Least Fuel Efficient Trucks]]</title>
Element tags need < >.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Find a string within a variable string PowerShell
problems with $var | select-string -pattern $string -q PowerShell
How export-csv deals with string versus string[] PowerShell
String PRODUCT_NAME was not found in string table Vista General
cdata-secstion question PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46