Jump to content
Sign in to follow this  

Traversing and Recording XML Paths

Recommended Posts

Hi there,


I have recently been trying to traverse the attached ASP-1.HVAC_Main.xml to try and replicate and write the folder structure contained to another XML.

I have been trying to use:

But have been having a lot of trouble with actually understanding the XML structure in accomplishing my task.


What I am trying to do is traverse down //ObjectSet/ExportedObjects, picking out OI elements and checking to see whether their attribute TYPE="system.base.Folder".

If it is then I want to be able to go down into that "Folder" and check to see whether there are any OI attributes with TYPE="trend.TLog" or TYPE="trend.TLogChangeOfValue". If not then look for another folder. If there are no other folders then back up to the folder before this folder and check the next folder (if applicable) and repeat.

So it would do something like this:

  • Air Conditioning - 1, 15
    • Indoor - 2, 7, 14
      • AC-1 - 3
        • Alarms - 4
        • Trends - 5
        • Values - 
      • AC-2 - 8
        • Alarms - 9
        • Trends - 10
          • Trend1.Log - 11
          • Trend2.Log - 12
        • Values - 13
    • Outdoor - 16, 21
      • AC-3 - 17
        • Programs - 18
        • Trends - 19
        • Values - 20
      • AC-4 - 22
        • Graphics - 23
        • Programs - 24
        • Trends - 25
          • Trend1.Log - 26
        • Values - 27

Output to my own XML would be an XML with structure (only record paths where a Trendlog or w/e TYPE I want to include is recorded):

  • Air Conditioning
    • Indoor
      • AC-2
        • Trends
    • Outdoor
      • AC-4
        • Trends

If there is that type then I want to be able to record that "Path" down to that Trend Log and save it into an XML with just the folders and not the items inside.

In the end I want to accomplish something that is reminiscent of my other attached file,  ExtendedTrendLogs.xml.


From what I can tell from the xml UDF functions, I can only get ALL elements of a certain type instead of checking and delving further into the "next" OI element nested within the first OI element which is of TYPE="system.base.Folder".


Any help is appreciated!!!





Edited by Hiyoal
Added clarification to question

Share this post

Link to post
Share on other sites

I think (I'm not sure since I've never used the UDF) that you're looking for the function _XML_GetChildNodes.

To solve the whole thing, I (personally) would try making a recursive function that builds the folder structure as it goes. If you're looking for more, let me know :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.


My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post

Link to post
Share on other sites

Yeah gotcha. 

I was tinkering yesterday and came to this conclusion. I've been having trouble with the getchildnodes function as its throwing weird errors. 


Ive asked the udf support thread about this so Ill see how I go. 

Share this post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...