XML to a String

Post Reply
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

XML to a String

Post by actionHero »

Hello,
Any ideas on how to evaluate the contents of entire XML to a string for us in a script?

Thanks!
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: XML to a String

Post by cstevens »

Just read it in like a normal text file:

Code: Select all

var xmlString = File.read(job.getPath());
I've used this in the past with regular expressions to find something without knowing where it is in the XML structure, or in XML formats that aren't supported in Switch like cXML. I believe you need to be careful if you're modifying anything though. Make sure to write it back out as UTF-8 and be careful of any non-valid XML characters.
Post Reply