Hey all,
I am trying to use DOMDocument to access an XML file, find data that matches a certain criteria, and then drop the node containing it if it does. I then need to create a new XML file with the remaining data.
Below is the function I am using, with $current_balances being the full path to the XML file that i wish to use. I am looking for a specific transaction date (which I will change to a variable one this is working), and if that date is found then I need to drop the node that is associated with that date.
The porblem though is that I keep getting the following error, and I cannot figure out why -
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Start tag expected, '<' not found in Entity, line: 1
I hope that makes sense, and I hope someone is able to help.
Thanks.
function get_xml_data($current_balances = null){
$doc = new DOMDOcument;
$doc->loadxml($current_balances);
$xpath = new DOMXpath($doc);
foreach($xpath->query('//data[record/LastAccountsTransactionDate="2010-10-08"]') as $node) {
$node->parentNode->removeChild($node);
}
echo $doc->savexml();
}