Jump to content

PHP, xPath and Transversing


ilude

Recommended Posts

Hey all,

 

Here's dilemma - I'm working with xPath to drill-down into XML, but now I need to go back UP the XML tree.

XML:[pre]

<?xml version="1.0" encoding="UTF-8"?>

<Report>

  <Enterprises>

    <Enterprise id="" status="4">

      <Name>entName</Name>

      <Divisions>

        <Division id="" status="4">

          <Name>mydomain.com</Name>

          <Users>

            <User id="" status="">

              <OriginialUsername>username</OriginialUsername>

              <OriginialPassword>password</OriginialPassword>

              <NewUserName>newusername</NewUserName>

              <Errors/>

            </User>

          </Users>

        </Division>

        <Division id="" status="4">

          <Name>anotherdomain.com</Name>

          <Users>

            <User id="" status="">

              <OriginialUsername>username</OriginialUsername>

              <OriginialPassword>password</OriginialPassword>

              <NewUserName>newusername</NewUserName>

              <Errors/>

            </User>

          </Users>

        </Division>

      </Divisions>

      <Errors>

        <Error id="806" severity="4">

          <Name>Call to API failed.</Name>

          <Detail><![CDATA[]]></Detail>

        </Error>

      </Errors>

    </Enterprise>

[/pre]

 

What I need is every Division->Name where the Enterprise has an Error with the id=806. The xPath query '/Report/Enterprises/Enterprise/Errors/Error[@id=806]' will get me to the Error and it's children, how can I go back UP the tree?

Link to comment
https://forums.phpfreaks.com/topic/154414-php-xpath-and-transversing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.