Page 1 of 1

XML to a String

Posted: Thu Dec 06, 2018 10:16 pm
by actionHero
Hello,
Any ideas on how to evaluate the contents of entire XML to a string for us in a script?

Thanks!

Re: XML to a String

Posted: Thu Dec 06, 2018 10:59 pm
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.