XML属性中的XML字符串

时间:2014-09-08 11:52:52

标签: xml attr

我有以下XML(字符串)输出,我希望得到结果属性值(xml字符串:<result>):

<task finished="True" 
    started="True" 
    succeeded="True" 
    hasDependantTasks="False" 
    processingTime="62" 
    totalTime="439" 
    threadNum="6" 
    creationTime="2014-09-08 12:36:42" 
    taskType="pdfGeneration" 
    baseURL="http://ded02.peleman.com/chili/" 
    waitForTaskID="" 
    id="ebca0271-5552-4940-aa5a-7c7816ff5593" 
    userID="e86313ff-7917-4e8a-9871-5e1e6a228a32" 
    userName="unibindprint-dev" 
    itemXML="" 
    hasEditorCliLog="False" 
    userEnvironment="unibindprint-dev" 
    environmentName="unibindprint-dev" 
    itemID="7e857bd8-333c-4707-aae2-74e13e332fbc" 
    itemName="" 
    resourceName="Documents" 
    result="&lt;result path=&quot;C:\CHILI_Publisher\data\temp\b6fc27ff-8a50-4e92-96e7-7de6925774ef\e7d188f0-34b3-4456-bc5b-b5235940c47d\A4_P_wraparound.pdf&quot; openInBrowser=&quot;true&quot; url=&quot;http://ded02.peleman.com/chili/unibindprint-dev/download_tempFile.aspx?path=%5cb6fc27ff-8a50-4e92-96e7-7de6925774ef%5ce7d188f0-34b3-4456-bc5b-b5235940c47d%5cA4_P_wraparound.pdf&quot; relativeURL=&quot;unibindprint-dev/download_tempFile.aspx?path=%5cb6fc27ff-8a50-4e92-96e7-7de6925774ef%5ce7d188f0-34b3-4456-bc5b-b5235940c47d%5cA4_P_wraparound.pdf&quot; /&gt;" 
     errorMessage="" 
     errorStack="" 
     settingsName="wraparound" 
     saveDocIfNeeded="True" />

我尝试使用新的SimpleXMLElement,但该属性为空。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

DOM获取它。

$dom = new DOMDocument();
$dom->loadXML($xml);
echo $dom->documentElement->getAttribute('result');

输出:

<result path="C:\CHILI_Publisher\data\temp\b6fc27ff-8a50-4e92-96e7-7de6925774ef\e7d188f0-34b3-4456-bc5b-b5235940c47d\A4_P_wraparound.pdf" openInBrowser="true" url="http://ded02.peleman.com/chili/unibindprint-dev/download_tempFile.aspx?path=%5cb6fc27ff-8a50-4e92-96e7-7de6925774ef%5ce7d188f0-34b3-4456-bc5b-b5235940c47d%5cA4_P_wraparound.pdf" relativeURL="unibindprint-dev/download_tempFile.aspx?path=%5cb6fc27ff-8a50-4e92-96e7-7de6925774ef%5ce7d188f0-34b3-4456-bc5b-b5235940c47d%5cA4_P_wraparound.pdf" />