Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Read CData in TJvSimpleXML


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 10, 2017 12:03 AM Last Post By: mohamed alayadi
mohamed alayadi

Posts: 17
Registered: 8/26/02
Read CData in TJvSimpleXML  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 8, 2017 3:31 AM
I use TJvSimpleXML to read an XML file but i am unable to read the element value when the type is CData even if i cast to TJclSimpleXMLElemCData, i tried Value, AnsiValue etc of the Items[i].
The curious thing is that the same file is read just fine with the TJvXMLBrowserControl which shows CData elements correctly. An example would be :
<name><![CDATA[CHRISTINE]]></name>
I should be missing something, i will be thankful for any hint..
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Read CData in TJvSimpleXML  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 8, 2017 11:10 AM   in response to: mohamed alayadi in response to: mohamed alayadi
mohamed wrote:

I use TJvSimpleXML to read an XML file but i am unable to read the
element value when the type is CData even if i cast to
TJclSimpleXMLElemCData, i tried Value, AnsiValue etc of the Items[i].

According to the following discussion that I found online:

http://www.delphipraxis.net/121066-tjvsimplexml-und-cdata-lesen.html

(translated to English)

After 20min try and debug now here (in the after all actually logical) explanation:
JclSimpleXML saves "<! [CDATA [" elements as a separate tag! After all,
it is not a normal text in the conventional sense and is also valid within
the XML space - as far as I know - as a separate tag.

Important : own element below the "actual" tag. And: the tag name is empty
( '' )!

I'll stick with the detailed example: you can not just access the text by:

Items.Value('Graphic');

Instead, you must call the item with the name '' below Graphic:

Items.ItemNamed['Graphic'].Value('');

As a result, access to the CDATA is now finally working!

Followed by the reply:

Thank you, your solution hinweis helped me very much! THANK YOU THANK YOU
THANK YOU!!!

For me the following syntax has worked to read out CDATA:

Code:
Items.ItemNamed['Graphic'].Items.Value('');

So, in your case, just replace 'Graphic' with 'name'.

--
Remy Lebeau (TeamB)
mohamed alayadi

Posts: 17
Registered: 8/26/02
Re: Read CData in TJvSimpleXML  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 10, 2017 12:03 AM   in response to: mohamed alayadi in response to: mohamed alayadi
Thansk very much..
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02