[Xerte] Re: address CDATA?

Julian Tenney Julian.Tenney at nottingham.ac.uk
Mon Aug 15 13:11:05 BST 2011


It's how xmlToObject handles it: it's basically creating an array / object based on the names it finds in the xml: it finds a CDATA node and rather than create

myNode[0].CDATA[0].text it creates myNode[0].text.

Just the way it functions I guess.

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 15 August 2011 12:32
To: Xerte list
Subject: [Xerte] Re: address CDATA?

I can.
I'm just curious why I can't get at it.

I tried a couple variations on the firstChild.nodeValue thing and couldn't get that to work either.


It just seems dopey that if for instance I'm receiving a dynamic xml structure back from a server call that I can do


sometextid.setText(interfaceData.pages[0].page[0].id); // an attribute


or



remove the CDATA tags and have setText work correctly.



but if I encounter CDATA tags in the data I'm forced to recast type?






________________________________
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Mon, 15 Aug 2011 12:20:53 +0100
Subject: [Xerte] Re: address CDATA?
Not sure. From the xml directly it's via firstChild (it see the CDATA as a child node), but xmlToObject obviously drops the object itself into the array.

But this isn't the problem: if it were reporting 'object' then you'd see 'object' on the screen, not undefined.

Why can't you re-cast it?

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 15 August 2011 12:03
To: Xerte list
Subject: [Xerte] Re: address CDATA?



:-) Yes I know I can recast it.


But how do I get directly to the string within the CDATA tags?


debug( interfaceData.pages[0].page[0].intro_text[0]) // shows "blah" in the debug window
debug(typeof interfaceData.pages[0].page[0].intro_text[0]) // reports "object"




sometextid.setText(interfaceData.pages[0].page[0].intro_text[0]);


Says undefined on screen  (because it's reporting as an object?)












From: Julian.Tenney at nottingham.ac.uk

To: xerte at lists.nottingham.ac.uk
Date: Mon, 15 Aug 2011 11:32:50 +0100
Subject: [Xerte] Re: address CDATA?
String(your[0].expression[0].here);

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 12 August 2011 15:50
To: Xerte list
Subject: [Xerte] address CDATA?



Senior moment.


What's the syntax for addressing the CDATA content so it comes out as typeof = string?




<content>
<pages>
   <page id="1">
      <intro_text>
-                 <![CDATA[blah]]>
          </intro_text>






interfaceData = ifc.templateData.content[0];


debug(typeof interfaceData.pages[0].page[0].intro_text[0]);
//gives me "object"


How do I get at the string directly?
I know I could put it in a variable and re-type it, but I want to set text directly:


sometextid.setText(interfaceData.pages[0].page[0].intro_text[0]);
//displays undefined - because it's an object











This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20110815/ca7b7da4/attachment-0001.html>


More information about the Xerte mailing list