How to load an external xml into script

Post Reply
Qpdv
Member
Posts: 22
Joined: Thu Dec 03, 2015 2:59 pm

How to load an external xml into script

Post by Qpdv »

Hello,

I need to create an order xml. Somewhere on the serve i have a base xml file which i would like to load, then change some values and store that xml as private data in the job.

First i tried to load the xml via XMLHttpRequest (which didn't work... obviously :D ).

Now i have xmlDoc = new Document(baseXmlPath);

but every time switch tries to load the xml is says "Invalid XML Document: C:/path/to/doc.xml" (tried all sort of slashes).

Now the question is how can do this "xmlDoc.getElementsByTagName("orderrefid")[0].childNodes[0].nodeValue = orderrefid;" in Switch?

Thanks in advance :)
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: How to load an external xml into script

Post by gabrielp »

Try the inject configurator. You can pick up the file (or a copy of it) and then do metadata pickup.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Caiofabio
Newbie
Posts: 4
Joined: Tue Feb 23, 2016 3:12 pm

Re: How to load an external xml into script

Post by Caiofabio »

Qpdv wrote: but every time switch tries to load the xml is says "Invalid XML Document: C:/path/to/doc.xml" (tried all sort of slashes).
In my opinion there are syntax errors in the xml file.
Also check the encoding of the XML file. Is UTF8?
Post Reply