How to get XML nodes content when names include special Characters?

Posted by paoloi on Stack Overflow See other posts from Stack Overflow or by paoloi
Published on 2013-10-24T15:47:40Z Indexed on 2013/10/24 15:53 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

Im trying to navigate an XML block similar to this one ($doc) using PHP simplexml_load_string and using xpath on $doc to get only the 'Day' block like this:

$myday = $doc->xpath ('//Day');

that lets me access all data from the block as an object, meaning $doc->AdultCount returns 1 and $doc->Id returns "6a0" however I can't access "SpecialDeals" content not using: $doc->SpecialDeals nor using: $doc->SpecialDeals->a:string Whats is the right syntax in this case? Thanks in advance.

<Days>
  <DaysId>687</DaysId>
    <Day>
      <AdultsCount>1</AdultsCount>
      <Availability>Available</Availability>
      <Id>6a0</Id>
      <RoomType>Studio</RoomType>
      <SpecialDeals xmlns:a="http://microsoft.com/2003/Arrays">
        <a:string>Best Day Ever</a:string>
      </SpecialDeals>
    </Day>
  <DaysPrice>247.4</DaysPrice>
</Days>");

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml