use php to strip non-xml from xml doc, save as new xml

jmsnjjmsn

New Member
I have an xml file called distribution_lists_tmp.xml that has irrelevant text before and after the actual xml. I want to strip all of that away and save it as distribution_lists.xmlI know this isn't correct, but am I at least on the right track?\[code\]function stripheaders { String s = getContent( "distribution_lists_tmp.xml" ); int xmlIndex = s.indexOf( "<?xml" ); s = s.substring( xmlIndex ); xmlIndex = s.lastIndexOf( ">" ); s = s.substring( 0, xmlIndex ); $doc = new DOMDocument(); $doc->formatOutput = true; echo $doc->saveXML(); $doc->save("distribution_lists.xml") }\[/code\]
 
Back
Top