+ Reply to Thread
Results 1 to 6 of 6

Loop through XML file and get nodes

  1. #1
    Registered User
    Join Date
    01-17-2020
    Location
    Denmark
    MS-Off Ver
    2015
    Posts
    3

    Loop through XML file and get nodes

    Hi

    This is my first post on this website, i've been using the forum alot over the years, but the time has come for me to post a problem that i cant solve myself.

    I'm trying to get some data from a XML file, my issue is that the XML file can vary, but the node names will be the same, but the amount of nodes will vary. I've attached a picture of the issue.

    The Data does not come in the same order as in the XML. I've attached both the excel and the XML that i i've tested it on.

    Img.PNG

    Please Login or Register  to view this content.
    I hope some of you have the time and to help me.
    Attached Files Attached Files
    Last edited by AliGW; 01-18-2020 at 10:04 AM.

  2. #2
    Registered User
    Join Date
    01-17-2020
    Location
    Denmark
    MS-Off Ver
    2015
    Posts
    3

    Re: Loop through XML file and get nodes

    I've got i working by looping through the XML and if the the parameter i was looking for didnt occur, then it will just resume next.

    I'll leave the code here, if someone happens to have the same problem.

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,887

    Re: Loop through XML file and get nodes

    Thanks, but next time, please do NOT edit the original post - the thread is not much use to anyone if the problem is missing! I have reinstated the original message.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Valued Forum Contributor
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (24 H2) 64 Bit
    Posts
    1,187

    Re: Loop through XML file and get nodes

    @CasperVest ;

    Using "On Error Resume Next" statement is not good actually, because it suppresses all kinds of errors if exists and you cannot rely on the results you get. Also, you have to close the unchecking error procedure by placing a "On Error GoTo 0" statement immediately after when you are satisfied with unchecking the errors.

    Having said this, you can try the code below where instead of "On Error Resume Next - On Error GoTo 0" statements, the existence of XML nodes are checked....

    Note that, the related XML should be placed with Excel file in the same folder.

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (24 H2) 64 Bit
    Posts
    1,187

    Re: Loop through XML file and get nodes

    And, the following code eliminates the first For-Next loop in your original code because; "Level-2" nodes are selected first, and therefore we only need just one For-Next loop to get the results.....


    Please Login or Register  to view this content.

    .
    Last edited by Haluk; 01-18-2020 at 03:29 PM.

  6. #6
    Registered User
    Join Date
    01-17-2020
    Location
    Denmark
    MS-Off Ver
    2015
    Posts
    3

    Re: Loop through XML file and get nodes

    Hi Haluk, thank you for taking a look at the code, i see your point for not using "on error". Your suggestion is definitely better, so i will go with that.

    Thank you so much for the answer!

    Sorry about the edit of the post, did not see that it changed the whole post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. find all path between any two nodes in a loop graph
    By sks4444 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2020, 04:12 PM
  2. Finding Values in Nodes and Child Nodes in XML SOAP POST
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2018, 11:33 AM
  3. VBA Loop through nodes
    By devatu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2015, 06:47 AM
  4. How to loop through multiple XML nodes in VBA?
    By mockions in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-03-2015, 01:35 PM
  5. Replies: 1
    Last Post: 11-01-2013, 03:22 PM
  6. Shape Nodes
    By incjourn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-08-2010, 03:53 PM
  7. Creating Nodes
    By Andy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2005, 03:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1