When the existing PHP code outputs an XML node, it can only output the content of the first node with the same name & quot; 100 & quot;. How can I output the content of all nodes? Existing Code: & amp; lt ;? Php * $ xmlstring original content: & amp; lt ;? XML version & quot; 1.0 & quot ;? & Amp; gt; & amp; lt ;! DOCTYPEGetUserInfo & amp; gt;-& amp; lt; Get... when the existing PHP code outputs an XML node, only the content of the first node with the same name "100" can be output ". how can I output the content of all nodes?
Existing Code:
/* $ Xmlstring original content:
-
Id * cn
100
101
102
103
105
*/
$ Xmldoc = new DOMDocument ();
$ Xmldoc-> loadXML ($ xmlstring );
$ Users = $ xmldoc-> getElementsByTagName ('getuserinfo ');
Foreach ($ users as $ user ){
$html .= 'outputCustomer:'.get_txt($user,'Customer').'
';$html .= 'outputGeo:'.get_txt($user,'GeocallCLI').'
';
}
Echo $ html;
Function get_txt ($ parent, $ name ){
$nodes = $parent->getElementsByTagName($name);return $nodes->item(0)->nodeValue;
}
?>
How to output only Id Cn NodeId, not id * cn
Reply content:
When the existing PHP code outputs an XML node, it can only output the content of the first node with the same name "100". How can I output the content of all nodes?
Existing Code:
/* $ Xmlstring original content:
-
Id * cn
100
101
102
103
105
*/
$ Xmldoc = new DOMDocument ();
$ Xmldoc-> loadXML ($ xmlstring );
$ Users = $ xmldoc-> getElementsByTagName ('getuserinfo ');
Foreach ($ users as $ user ){
$html .= 'outputCustomer:'.get_txt($user,'Customer').'
';$html .= 'outputGeo:'.get_txt($user,'GeocallCLI').'
';
}
Echo $ html;
Function get_txt ($ parent, $ name ){
$nodes = $parent->getElementsByTagName($name);return $nodes->item(0)->nodeValue;
}
?>
How to output only Id Cn NodeId, not id * cn
Which of the following experts can answer this question?
My top