High score online Help XML parsing
This post was last edited by Huenke on 2013-10-25 15:58:22
Type= "0" >
Structure for nodes under node and node below.
I want to do a triple loop.
foreach ()
{
Deposit Company Name
foreach ()
{
Name of the Depositary Department
foreach ()
{Save Leaf name}
}
}
How can I parse it, please? XML
Share to:
------Solution--------------------
What kind of data format do you want? , organize your data structure below.
$string = <<
<>
Type= "0" >
XML;
$xml = new SimpleXMLElement ($string);
$result = $xml->xpath ([email protected] ');
while (list (, $node) = each ($result)) {
echo [email protected]: ', $node, ' \ n ';
}
$result = $xml->xpath ([email protected] ');
while (list (, $node) = each ($result)) {
echo [email protected]: ', $node, ' \ n ';
}
$result = $xml->xpath ('//node[@type =1]/. [email protected] ');
while (list (, $node) = each ($result)) {
echo [Email protected]_id: ', $node, ' \ n ';
}
$result = $xml->xpath ('//node[@type =2]/. [email protected] ');
while (list (, $node) = each ($result)) {
echo [Email protected]_id: ', $node, ' \ n ';
}
?>
------Solution--------------------
$s =<<< XML
Type= "0" >
XML;
$xml = simplexml_load_string ($s);
foreach ($xml->node as $node) {
foreach ($node->attributes () as $k + $v) echo "$k = $v \ n";
foreach ($node->node as $node) {
foreach ($node->attributes () as $k + $v) echo "$k = $v \ n";