日期:2014-05-16 浏览次数:20525 次
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>zhangjian</cas:user>
<cas:language></cas:language>
</cas:authenticationSuccess>
</cas:serviceResponse>
$str = <<<EOT
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>zhangjian</cas:user>
<cas:language></cas:language>
</cas:authenticationSuccess>
</cas:serviceResponse>
EOT;
/*
$validateXML = simplexml_load_string($str);print_r($validateXML);
$successnode = $validateXML->authenticationSuccess[0];
var_dump($successnode);
*/
$xml = new DOMDocument();
$xml -> loadXML($str);
var_dump($xml);
<xmp>
<?php
$str = <<<EOT
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>zhangjian</cas:user>
<cas:language></cas:language>
</cas:authenticationSuccess>
</cas:serviceResponse>
EOT;
$validateXML = simplexml_load_string($str, null, 0, 'cas', true);
print_r($validateXML);
$successnode = $validateXML->authenticationSuccess[0];
print_r($successnode);
$xml = new DOMDocument();
$xml -> loadXML($str);
print_r($xml);
SimpleXMLElement Object
(
[authenticationSuccess] => SimpleXMLElement Object
(
[user] => zhangjian
[language] => SimpleXMLElement Object
(
)
)
)
SimpleXMLElement Object
(
[user] => zhangjian
[language] => SimpleXMLElement Object
(
)
)
DOMDocument Object
(
[doctype] =>
[implementation] => (object value omitted)
[documentElement] =>&