These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

read and parse xml from different file (adobe javascript)?

winata
Registered: Sep 22 2008
Posts: 8

Hello,

Does anyone know how to read/load and parse a xml file to a different file, in adobe javascript?

In javascript this can be accomplished by
var xmlDoc = null;
if ( xmlDoc != null)
{
xmlDoc.async=false;
xmlDoc.load("file name");

var x=xmlDoc.getElementsByTagName("tagName");
.
.
.
}

But, how to do this in adobe javascript?

Thank you,
Winata.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
It's not clear to me what you're trying to accomplish, but the following might get you started: http://www.windjack.com/DownLoads/XMLData_Example.pdf

It uses an attached file (data object) as the XML source, but you can also use the doc.importDataObject method.

More information on all of this is in the Acrobat JavaScript Reference.

George
winata
Registered: Sep 22 2008
Posts: 8
Hello,

Sorry not to make my question clear.
What I'm trying to accomplish is to read, parse a xml field from an external file and save it to a variable.

I'm able to read, parse the xml and store if it's located in the same file.
Here's what I know so far, the code:
-------------------------------------------------------------------------------------
// create the XML stream
var myXML =

Patient First Name
Patient Last Name//now convert to a string so we can use XMLData.parse()
var parseString = myXML.toXMLString();

//now create the DOM
var x = XMLData.parse(parseString);

var one = x.nodes.item(0);
var two = x.nodes.item(1);
.
.
.
then ... output --> one.field1.value ; //this part is just a pseudocodeSo, in the output, we will see "Patient First Name"
-------------------------------------------------------------------------------------

But then again, the above code will work if the xml fields are located in the same file with the rest of the code.

My question is, how to read, parse a xml file/field that is located in a different file?


Thank you,
Winata.