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

How to extract data from xml field to dropdown list?

Avatar

Level 2

Hi,

I have designed a form and connected to a SQL server database using a web service. The XML data retrieved from wsdl connection is currently hold in a text field called 'XMLfield'. I need to extract the data such as 'PersonnelName' from XMLfield into a dropdown list. I used the following code and I do not get any error, but nothing come up and all my fields in the forms become bank when i click the dropdown list.

I would appreciate it if anyone can help me with this issue.

form1.DropDownList::click - (JavaScript, client)

xfa.datasets.data.loadXML(form1.XMLfield.rawValue,0,1);
form1.XMLfield.rawValue = xfa.datasets.data.saveXML();

var dataGroup = xfa.resolveNode("xfa.data.Timesheet.Personnel.PersonnelName");
var dataGroupLength = dataGroup.nodes.length;

if (dataGroupLength == 0) {
  xfa.host.messageBox("There are no parts in the XML doc");
}
else {
  for (var i=0; i < dataGroupLength; i++){
    this.addItem(dataGroup.nodes.item(i).nodes.item(0).value);
  } 
}

Thanks,

Roya

2 Replies

Avatar

Level 10

Hi Roya,

I think the loadXML will override your form data, so blanking out your fields.  You could try loading the xml data at the xfa.datasets level (that is xfa.datasets.loadXML(form1.XMLfield.rawValue,0,1);) or using E4X to process the XML.

Another option though might be more rework is to use the Acrobat SOAP api which will return you a JavaScript object so you wont have to do any XML work.

There's a good intro to the SOAP api here, http://www.avoka.com/blog/page/11/.

Regards

Bruce

Avatar

Level 2

Thanks Bruce, I have created an xml schema and bind the data to the schema and it seems to work. The customise SOAP api seems a good approach too and I will try this later.

Regards,

Roya