Jump to content

XML not working in simplexml_load_string


ttpparker

Recommended Posts

I am trying to parse the following XML using simplexml_load_string.

 

<?xml version="1.0" encoding="utf-16"?>
<rialtowebordersresponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ReturnStatus="1" xmlns="http://schemas.redarrow.co.uk/rialto">
<orders />
<errors>
<error OrderNo="BSTN4" ErrorCode="10010" ErrorMessage="Order already added" />
</errors>
</rialtowebordersresponse>

 

When I var_dump the variable I just get:

 

bool(false).

 

Anyone have any ideas why?

 

Thanks

 

Tony

 

do you have php's error_reporting/display_errors turned on?

 

i get php warnings (whcih could be due to copy/pasting the text of your xml out of the forum) about - Document labelled UTF-16 but has UTF-8 content

 

beyond that, you would probably need to post your code.

That XML looks valid. We need to see some code.

 

i get php warnings (whcih could be due to copy/pasting the text of your xml out of the forum) about - Document labelled UTF-16 but has UTF-8 content

It's possible, even likely, that during the copy/paste into the post the text was automatically converted from UTF-16 to UTF-8.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.