Jump to content


Photo

XML not working in simplexml_load_string


  • Please log in to reply
3 replies to this topic

#1 ttpparker

ttpparker

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 16 July 2013 - 08:47 AM

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

 



#2 mac_gyver

mac_gyver

    Advanced Member

  • Moderators
  • 1,901 posts

Posted 16 July 2013 - 11:51 AM

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.


multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]

#3 requinix

requinix

    Playful Member

  • Moderators
  • 5,747 posts
  • LocationWA

Posted 16 July 2013 - 12:48 PM

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.

#4 ttpparker

ttpparker

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 17 July 2013 - 03:11 AM

Never mind, I got it working.

 

Thanks anyway.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com