473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CDATA problem

Hello,

I need a little help. I want to read the CDATA from an XML file :
....
<EpgDescription>

<![CDATA[ Matrix]]>

</EpgDescription>
....

I use this code to read the CDATA:

Node EpgDescription =
XPathAPI.selectSingleNode(ScheduleNodeListNode,"Ep gDescription");

Node firstchild = EpgDescription.getFirstChild();

System.out.println("start
:"+firstchild.getNodeName()+"-"+firstchild.getNodeValue()+" :end");

The problem is when i Print my node name and my node value on the
screen. I see this:

start :#text-
:end
How can I print Matrix?

Thx

Dec 15 '05 #1
5 1484
be*****@hotmail.com wrote:
<EpgDescription>

<![CDATA[ Matrix]]>

</EpgDescription> [...] System.out.println("start
:"+firstchild.getNodeName()+"-"+firstchild.getNodeValue()+" :end");

The problem is when i Print my node name and my node value on the
screen. I see this:

start :#text-
:end


The CDATA section is not the first child node of the EpgDescription
element. It's text node with white space. Try looping over all child
nodes and concatenate the values.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Dec 15 '05 #2
Hello,

Your code is correct but the problem is in your document structure, if
you don't have a DTD or a Schema W3C, your blank text will be considered
as text node too so your first child node is not the CDATA part but the
previous blank part.

Best wishes,

A.Brillant
EditiX - XML Editor and XSLT Debugger
http://www.editix.com

be*****@hotmail.com wrote:
Hello,

I need a little help. I want to read the CDATA from an XML file :
...
<EpgDescription>

<![CDATA[ Matrix]]>

</EpgDescription>
...

I use this code to read the CDATA:

Node EpgDescription =
XPathAPI.selectSingleNode(ScheduleNodeListNode,"Ep gDescription");

Node firstchild = EpgDescription.getFirstChild();

System.out.println("start
:"+firstchild.getNodeName()+"-"+firstchild.getNodeValue()+" :end");

The problem is when i Print my node name and my node value on the
screen. I see this:

start :#text-
:end
How can I print Matrix?

Thx

Dec 15 '05 #3
Thx guy's

Problem is solved by loping all the childnodes i found the problem.
there are 3 childnode's
The first and last node are null.
the second contains the Matrix

THX

Regards

Marco

Dec 15 '05 #4
be*****@hotmail.com wrote:
The first and last node are null.


Well, not null, but whitespace.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Dec 15 '05 #5
Indeed

Dec 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
12
by: Peter Michaux | last post by:
Hi, I am experimenting with some of the Ruby on Rails JavaScript generators and see something I haven't before. Maybe it is worthwhile? In the page below the script is enclosed in //<!]> ...
7
by: Max | last post by:
Hello everyone! Can anyone help me to convert the CDATA expression "CDATA ::= (Char* - (Char* ']]>' Char*)" to Javascript Regular Expression? Thanks, Max
6
by: dkyadav80 | last post by:
Hi sir, I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be store in xml file. when user select city then all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.