【发布时间】:2012-05-29 05:45:12
【问题描述】:
我有一个从其他服务器动态获取其值的字符串。 字符串的值为
$string1 = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.microsoft.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AuthenticateUserResponse xmlns="http://microsoft.com/xml/namespace/2012/04">
<Authenticator>AE1001</Authenticator>
</AuthenticateUserResponse>
</soap:Body>
</soap:Envelope>';
我的问题是,通常我们使用 *$xml = simplexml_load_file("test1.xml");* 来加载 XML 文件,但在我的要求中它是一个 String,我该如何阅读这个字符串值并提取子节点及其值?示例:
<Authenticator> and its value "AE1001" ?
有没有办法把它放到数组中?这样我就可以轻松打印出它的节点值?
【问题讨论】: