How to get XML nodes content when names include special Characters?
- by paoloi
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>");