Jump to content

Recommended Posts

Posted

Hi I am a bit stuck with reading an XML file, I can get most of it to work but one thing I cant work out.

This is an example of my data file for ease.

 

<XML>
<Check ID="123" Name="test">
<Detail>
	<Data ID="456" ID2="567">
    <Title>
    	This is the title
    <Other>
<Check ID="678" Name="test">
<Detail>
	<Data ID="999" ID2="666">
    <Title>
    	This is the title2
    <Other>

I have the following code working that gets the ID and ID2 from the Data section within (XML/Check/Data), but I just cant work out how do I get the title for each Data entry ID I extract. It doesn't have an element I can use.?

$sFile = "myfile.xml"
        $oXML = ObjCreate("Microsoft.XMLDOM")
        $oXML.load($sFile)

        $xmlquery = $oXML.SelectNodes('//XML//Check/Detail/Data')


        For $xml In $xmlquery
            $id = $xml.GetAttribute("ID")
            $id2 = $xml.GetAttribute("ID2")
            
            ConsoleWrite($id & $id2 & @CRLF)
         Next

This works and I get back "456" and "567", "999", "666" etc as it loops, but I also want the Title values for each one.

Any suggestions please? thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...