How can I use XPath to read in an XML document, run a query to filter out some of the data and then save the filtered data as a new XML file?
It would be a huge help if you posted an example of what the XML document should look like before and after processing.
You'll probably find it easier to use simpleXML, but the basic method for parsing with XPath is: $xml = file_get_contents('yourxml.xml'); $dom = new DOMDocument(); @$dom->loadXML($xml); $xpath = new DOMXPath($dom); $xml_nodes = $xpath->evaluate("/your/xpath/goes//here"); foreach ($xml_nodes as $nodes) { echo $nodes->firstChild->data; } PHP:
OK I've already got that far, I need it to run a query to filter out some of the data and then save the filtered data as a new XML file.