Posted by fido on 07/07/07 04:59
Here's a bit of xml code that works.
<?php
$string =
"<?xml version=\"1.0\" standalone=\"yes\"?>
<world>
<people xmlns:ss=\"http://crap\">
<person id=\"5\">John Doe</person>
<person id=\"2\">Susie Q. Public</person>
</people>
</world>";
$xml = simplexml_load_string($string);
print "<pre>\n";
print_r($xml);
print "</pre>\n";
foreach($xml->people->person as $p)
foreach($p->attributes() as $a => $b)
{
print "$a => $b<br />\n";
}
// prints out
// id => 5
// id => 2
?>
Now what if I change the first person to this
<person ss:id=\"5\">John Doe</person>
Anyone know how to get the id?
This is a question that is pertinent to an excel .xml file as
you'll get lines like this
<Cell ss:Index="3">stuff</Cell>
btw: there is a guide on ibm that tells you how to do this with php
and dom. I'm just wondering if there's a way to do it with simplexml.
thx.
Navigation:
[Reply to this message]
|