Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Accessing XML data

Avatar

Not applicable
Hi, hope somebody can help me with this:

I have xml as follows:

this is line 1
this is line 2


I want to acces this data from a script on a button. if it is not a repeating tag i access it like this

xfa.datasets.data.TestData.line.value

However, how do i access all the repeating tags one at a time in a for loop?
5 Replies

Avatar

Not applicable
You can take a look at this post to see if this is something that you are looking for?



http://www.adobeforums.com/cgi-bin/webx?128@@.3bbb220b

Avatar

Not applicable
If the you already have this in your datasets (i.e. repeating nodes), then you could access this by using

xfa.datasets.data.TestData.resolveNode("line[1]").value

Avatar

Not applicable
Thanks David,<br />next challenge i have with the same problem is determining how many lines there are - any ideas on this <br /><br />xfa.record.node.length tells me all the lines in the xml file and not just for the repeating tag i am interested in<br /><br />xfa.record.nodes.namedItem('line") gives me first one, but I can't get the next one<br /><br />xfa.record.nodes.item(var).value - gives me the contents of the lines but not the tag names<br /><br />all I really want to do is get each of the <line> data into an array so I can work with them

Avatar

Not applicable
Hi Chris,



To get all the line nodes you can use the resolveNodes method instead, which returns a collection of nodes instead of a single node returned by resolveNode



var oLineNodes = xfa.datasets.data.TestData.resolveNodes("line[*]");



oLineNodes.length will give you the number of elements in the collection and then use item to access each one using a for loop



EG:



for(var i=0; i<oLineNodes.length; i++)

{

??? = oLineNodes.item(i).value;

}



where ??? is something you want to do with the value.