Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Problem in Parsing an XML

Avatar

Former Community Member
I have saved the XML data into a variable and want to retrive the values in XML and store them in separate variables.While trying to do this with Parsing I encounter an error in DOM creation.I have tried out following codes in Form:Ready event.But those are not working.

When I place a messagebox on top of the line which creates DOM its displaying the message.But it is not displaying when I place it in line next to line which creates DOM.So i think it is problem with the line of Creating DOM.Please help me out.Its very urgent.I have delivery in 2 days.



var temp = xfa.resolveNode("$data.nodes.item(0)");



var test = temp.saveXML();



// Now create the DOM:



var x = XML.parse(test);



var policy = x.resolveNodes("policies");



var number = policy.item(0);



var company = number.getElement("CNACompany").value;







var temp = xfa.resolveNode("$data.nodes.item(0)");



var test = temp.saveXML();



// Now create the DOM:



var x = XMLData.parse(test,false);



var xPathExpr = "//data/policies/[PolicyNumber='WC 1234567890']";



var number = XMLData.applyXPath(x, xPathExpr);



With this code for creating DOM we are getting some junk value for 'x' as 57.13mm.



Thanks in Advance...

Pavan.
3 Replies

Avatar

Former Community Member
Hi,



I have not tried running the script however I would recommend naming 'x' to something else. When I read your comment about the junk you are getting, it made me think of a conflict between the 'x' variable declared in your script and the xfa 'x' attribute. I could be wrong but it's simple enough to try.



Hélène

Adobe Systems Inc.

Avatar

Former Community Member
Thank you for ur reply Helene.I tried with other variable name.In that case its not showing any value.I think 'x' corresponds to coordinates of focus.Can you please suggest any other I can create DOM??

Avatar

Former Community Member
Hi,

I'm not familiar with the XML.parse() or XMLData.parse() functions. I can't identify the XML or XMLData objects. They are not declared and they are not XFA objects.

Still, it looks like you need to get and set a form/data value.

Here is an example getting the value of a form field:

Your have the following form:



someText
otherText



Use the SOM expression of the CNACompany field to access its value:

var CNAValue = form1.policies.CNACompany.rawValue;

If the value is not merged in the form, try searching the data DOM instead. For example:

var CNAValue = xfa.record.policies.CNACompany.value;

To set the value of a form field or data value, do as follows:

form1.policies.CNACompany.rawValue = newValue;
xfa.record.policies.CNACompany.value = "newValue";

Note: to get/set a value from the data file use the value property. To get/set a value from a form field, use the rawValue property.

Hope this helps,
Hélène

Adobe Systems Inc.

FYI

The Adobe XML Form Object Model Reference posted on the Developer Center contains several scripting examples in Appendix A.

LiveCycle Developer Center
http://www.adobe.com/devnet/livecycle/designing_forms.html

Adobe XML Form Object Model Reference
http://www.adobe.com/devnet/livecycle/articles/Adobe_XML_Form_Object_Model_Reference.pdf