Expand my Community achievements bar.

value of text fields objects as xml data?

Avatar

Level 6
Hi,



Does anyone know if there is anyway of working with the text (rawvalue) of a text field as if it was xml (navigate throw nodes...). Of course the data assign to this object is a set of xml nodes.



Thank you
5 Replies

Avatar

Former Community Member
You can use the Acrobat XMLData object, and pass the rawValue of the field into the parse() method. Script could look something like this:

var myXML = XMLData.parse(TextField1.rawValue, false);
app.alert(myXML.data.field.value);

Where the XML in the text field looked like this:


some value


Chris
Adobe Enterprise Developer Support

Avatar

Level 6
Hi,



Is it possible to cycle thru one of the nodes that has other nodes? Because some nodes could have a number of child nodes non deterministic.



Thank you

Avatar

Former Community Member
You could use Acrobat's XMLData object to build a DOM with the rawValue and then move through it using SOM expressions or XPath. Something like:



var xmlData = XMLData.parse(TextField.rawValue);

var nodeList = xmlData.rootNode.someNode.nodes;

for (i = 0; i < nodeList.lenght; i++) {

console.println(nodeList.item(i).name);

}



where nodeList is a list of all children of someNode, and the loop will print the names of all the children under someNode.



Chris

Adobe Enterprise Developer Support