I am trying to parse a order export xml in PHP but I am having an issue when the xml has cardnumbers in it as they are encrypted. Below is a snippet of the xml and the error I am receiving. I am using $xml = new SimpleXMLElemen t($ox->xml); to parse the xml $ox->xml is the xml as a string pulled from an API. Is there a way to remove the cardnum from the string before passing it to SimpleXML?
XML Snippet (You will notice not all orders have a cardnum):
Error:
XML Snippet (You will notice not all orders have a cardnum):
Code:
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?> <VFPDataSet> <sqlresult> <orderno>1001</orderno> <custnum>1000</custnum> <cl_key>WEBF12</cl_key> <odr_date>2012-07-25T00:00:00</odr_date> <hold_type/> <perm_hold>false</perm_hold> <sys_hold>false</sys_hold> <ship_date>2012-07-25T00:00:00</ship_date> <ccheck>G</ccheck> <paymethod>CK</paymethod> <cashonly>false</cashonly> <cardnum>ÈòMh»ÚKj›Õ›Ïzs鄸“®ôLý[0¡ZÍ</cardnum> <cardtype>VI</cardtype> ... <edi>false</edi> </sqlresult> <sqlresult> <orderno>1005</orderno> <custnum>1001</custnum> <cl_key>NEWCUST</cl_key> <odr_date>2012-07-26T00:00:00</odr_date> <hold_type/> <perm_hold>false</perm_hold> <sys_hold>false</sys_hold> <ccheck/> <paymethod>CK</paymethod> <cashonly>false</cashonly> <cardnum/> <cardtype/> ... <edi>false</edi> </sqlresult> </VFPDataSet>
Error:
Code:
Warning: SimpleXMLElement::__construct(): input conversion failed due to input error, bytes 0x90 0x03 0x51 0x3B in C:\inetpub\wwwroot\automa
te\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): input conversion failed due to input error, bytes 0x90 0x03 0x51 0x3B in C:\inetpub\wwwroot\automa
te\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): encoder errorEntity: line 1202: parser error : PCDATA invalid Char value 30 in C:\inetpub\wwwroot\
automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): Entity: line 1202: parser error : PCDATA invalid Char value 25 in C:\inetpub\wwwroot\automate\expo
rtOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): Entity: line 1202: parser error : PCDATA invalid Char value 7 in C:\inetpub\wwwroot\automate\expor
tOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): Entity: line 1202: parser error : Premature end of data in tag cardnum line 1202 in C:\inetpub\www
root\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on l
ine 43
Warning: SimpleXMLElement::__construct(): Entity: line 1202: parser error : Premature end of data in tag sqlresult line 1191 in C:\inetpub\w
wwroot\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on l
ine 43
Warning: SimpleXMLElement::__construct(): Entity: line 1202: parser error : Premature end of data in tag VFPDataSet line 2 in C:\inetpub\www
root\automate\exportOrdHeader.php on line 43
Warning: SimpleXMLElement::__construct(): <cardnum>╦å{├╛▲├Ü┬«↓-├┐v┬▒ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on lin
e 43
Warning: SimpleXMLElement::__construct(): ^ in C:\inetpub\wwwroot\automate\exportOrdHeader.php on l
ine 43
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\inetpub\wwwroot\automate\exportOrdHeader.
php:43
Stack trace:
#0 C:\inetpub\wwwroot\automate\exportOrdHeader.php(43): SimpleXMLElement->__construct('<?xml version =...')
#1 {main}
thrown in C:\inetpub\wwwroot\automate\exportOrdHeader.php on line 43
Comment