Jump to content

Recommended Posts

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.


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

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")

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

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

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

Link to post
Share on other sites

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...