Expand my Community achievements bar.

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

XML data and webservice

Avatar

Former Community Member

I have a form with 2 drop downs and a fill in. All get data from a web service I created. The drop downs get their data from this xml that is populated in a couple of text fields:

Dropdown1txtfield:

<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="pardata"><clsStaffInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<EMPLOYEE_ID>123456789</EMPLOYEE_ID><name>PUBLIC, JOHN Q</name></clsStaffInfo></string>

<?xml version="1.0" encoding="utf-8" ?>

Dropdown2txtfield:
  <string xmlns="pardata"><clsSupervisorInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<EMPLOYEE_ID>987654321</EMPLOYEE_ID><Supervisor_Name>ANYMA N, JOHN T</Supervisor_Name></clsSupervisorInfo>

The third takes input from a text field (Employee ID), submits to the webservice and returns this to another text field:

<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="pardata"><clsEmployeeInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<Index>SMITH1234</Index> <EM_EMPLOYEE_ID>987651234</EM_EMPLOYEE_ID> <FIRST_NAME>JOHN</FIRST_NAME> <MIDDLE_INIT>Q</MIDDLE_INIT> <LAST_NAME>SMITH</LAST_NAME> </clsEmployeeInfo></string>

My problem is trying to append the returned XML to the dataset. I'm using this code to populate the staff drop down list:

xfa.datasets.loadXML(xfa.resolveNode("definitions.#subform.GetStaffResult").rawV alue

, false, false);

//test

XMLdata.rawValue

= xfa.datasets.saveXML("pretty");

var theDataGroup = xfa.datasets.string.clsStaffInfo.nodes;

var oNodes = xfa.datasets.string.clsStaffInfo.nodes;

var nodesLength = oNodes.length;

//xfa.host.messageBox(len);

var

ddlist = xfa.resolveNode("definitions.#subform.reviewer");

ddlist.clearItems();

ddlist.rawValue

= "";

for

(var i = 1; i < 18; i++) {

+1).value,theDataGroup.item(i).value);

//xfa.host.messageBox(theDataGroup.item(i).value + " " + theDataGroup.item(i + 1).value)

i

= i + 1

definitions.#subform[0].reviewer::change - (JavaScript, client)

xfa.resolveNode("definitions.#subform.ReviewerName").rawValue

= xfa.event.newText;

= xfa.resolveNode("definitions.#subform.reviewer").boundItem(xfa.event.change);

When I try to run this code for the second drop down (using

var theDataGroup = xfa.datasets.string.clsSupervisorInfo.nodes;

var oNodes = xfa.datasets.string.clsSupervisorInfo.nodes;

in place of the clsStaffinfo lines) I get nothing in the list.

I get nothing for the employee info either.

How do I append the second and third XML Loads to the first?

xfa.resolveNode("definitions.#subform.Reviewer_ID").rawValue

}

ddlist.addItem(theDataGroup.item(i

5 Replies

Avatar

Former Community Member

OK, do I append to <string xmlns="pardata"> or do I do a straight Load using xfa.datasets.loadXML?

Do I use the xfa.appendchild in a loop?

Any Ideas?

Avatar

Level 10

Try like below..

Create a hidden field and bind this field to the webservice return XML.

After you execute the webservice, this hidden field will be populated with the return XML.

Then use

     xfa.datasets.data.loadXML(hiddenField.rawValue, 1);

After the above line, you should be able to access the newly returned XML to populate the dropdown..

Thanks

Srini

Avatar

Former Community Member

Sirini, I'm already doing that. The problem arises when I try to add the second and third xml to the xml data.

The second and third xml loads don't show up in the xml dataset, and I'm not sure where to add them.

How do I append the 2nd and 3rd under the node that is created from the first LoadXML?

Avatar

Level 10

Can you try the below code..

Form1.Page1.dataNode.loadXML(vNewRowData.toString(), false, false);
xfa.form.recalculate;

Where Form1.Page1 are root nodes in the form and vNewRowData is the XML string that is returned from the webservice..

I don't have a webservice in my environment to test and provide you the sample..But we have used the above code to append an XML structure to the existing Data Node.

You can try and let me know if it still not works.. I will search for any webservice that returns an XML string for me to test.

Thanks

Srini

Avatar

Former Community Member

This is the XML that goes into textbox1:

<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="pardata"><clsStaffInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<EMPLOYEE_ID>123456789</EMPLOYEE_ID><name>PUBLIC, JOHN Q</name></clsStaffInfo></string>

<?xml version="1.0" encoding="utf-8" ?>

This goes in textbox2:

<string xmlns="pardata"><clsSupervisorInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<EMPLOYEE_ID>987654321</EMPLOYEE_ID><Supervisor_ Name>ANYMA N, JOHN T</Supervisor_Name></clsSupervisorInfo>

This goes in textbox3:

<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="pardata"><clsEmployeeInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">"<Index>SMITH1234</Index> <EM_EMPLOYEE_ID>987651234</EM_EMPLOYEE_ID> <FIRST_NAME>JOHN</FIRST_NAME> <MIDDLE_INIT>Q</MIDDLE_INIT> <LAST_NAME>SMITH</LAST_NAME> </clsEmployeeInfo></string>

After I load all 3 XML strings into the dataset, my problem occurs when I try to populate fields based on the xml data.

I now have 3 <string> ...</string> tags.

I use var oNodes = xfa.datasets.string.clsSupervisorInfo.nodes, var oNodes = xfa.datasets.string.clsStaffInfo.nodes and var oNodes = xfa.datasets.string.clsEmployeeInfo.nodes to return the data but get nothing back.