Jump to content

Parsing XML contains single quote


becu

Recommended Posts

<?php
$str = "<root>
        <name>test</name>
        <items>
            <item>
                <id>1</id>
                <title>john's bookstore</title>
            </item>
            <item>
                <id>2</id>
                <title>the bookstore</title>
            </item>
        </items>
        </root>";

$xml = simplexml_load_string($str);

echo '<pre>', print_r($xml, true), '</pre>';

foreach ($xml->items->item as $x)
{
    echo "$x->id : $x->title <br/>";
}
?>

results -->
1 : john's bookstore 
2 : the bookstore 

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.