cas検証にphpを使ったところ、相手がこんなxmlを返してきた
<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 = <<authenticationSuccess[0];var_dump($successnode);*/$xml = new DOMDocument();$xml -> loadXML($str);var_dump($xml);
SimpleXML も PHP5 以降に提供されるシンプルで使いやすい XML ツールのセットです
ただし、名前空間 (namespace) を含む XML には適用されません。
どうやって?
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] => (object value omitted) [actualEncoding] => [encoding] => [xmlEncoding] => [standalone] => 1 [xmlStandalone] => 1 [version] => 1.0 [xmlVersion] => 1.0 [strictErrorChecking] => 1 [documentURI] => file:///D:/AMP/web/ [config] => [formatOutput] => [validateOnParse] => [resolveExternals] => [preserveWhiteSpace] => 1 [recover] => [substituteEntities] => [nodeName] => #document [nodeValue] => [nodeType] => 9 [parentNode] => [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => [ownerDocument] => [namespaceURI] => [prefix] => [localName] => [baseURI] => file:///D:/AMP/web/ [textContent] => zhangjian )
ありがとうしつこいです、私はそれを解決する方法を使用しただけですが、それはそれほど良くありません
$str = <<authenticationSuccess[0];echo (string)$successnode->user;