Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Reading XML Data with Javascript

Avatar

Level 1

Hello,

Is it possible to read the xml data I connected to with Javascript.

For example, I am reading an XML file using the New Data Connection method, and the fields populate in my data view. However, I want to read the values of these fields. Could someone please point me down the right path to do this if it is even possible.

Thanks

8 Replies

Avatar

Former Community Member

The Data Connection reads the structure of the XML it does not import the data into the form. You have to import a data file to do that . The Data connection allows you to bind the nodes in the xml to specific fields on your form. Simply drag and drop the node that you want (from the DataConnection) onto the field that represents it and that sets up a binding expression. Now when you import data into the form the data will populate the fields "automagically"

Paul

Avatar

Former Community Member

Well I have been trying to pre populate a drop down list using the Data Connection/Binding method. I am using a sample XML file. It works in the preview mode, but for whatever reason when I save it and open it in Adobe Acrobat it will not pre populate. Do you have any ideas????

Avatar

Former Community Member

In PreView the data is read into the form for you (assuming you set the data file on the preview tab in Form Properties). Once you render the form you have to import the data file.

Paul

Avatar

Former Community Member

Is it possible to do this in the background without the end user having to perform this task??


Avatar

Former Community Member

I have only been working with LiveCycle for about 3/4 of a year. What is the easiest method to read a simple text file from the web everytime the pdf opens. Thanks for all your help Paul.

Avatar

Former Community Member

Well ....you can either have the user choose the file when the form opens or you can have an association between the data file and the form (in that case th euser woudl launch the data file) or you combine form and data using server products before the file is rendered.

Paul

Avatar

Former Community Member

I see what you are saying. Thanks for your help. However, this will not accomplish my goal. Are there any classes within the LiveCycle Javascript language that would enable me to read the source code of a url? For example, Python has the urllib which allows the developer to accomplish this task. Thanks again for all of your help.

Avatar

Former Community Member

Nevermind, I figured it out. I used FormCalc to get the url, and I assigned the content to a hidden field. I then used Javascript to pull the value from the hidden field. Here is the FormCalc script I used in case others have the same question:

//Get the content from a site

var test=Get("http://www.adobe.com")

//Assign the value to the hidden field
xfa.resolveNode("form1.#subform.Text1").rawValue=test

or the even shorter version:

//Get and Assign value in one step

xfa.resolveNode("form1.#subform.Text1").rawValue=Get("http://www.adobe.com")