Solved

closest method in vb script xml

Posted on 2014-04-19
2
187 Views
Last Modified: 2014-04-21
in vb script is there a way to find the closest instance of a node working up the node tree, similar to closest in jquery.


<xml>
   <outer attr="thisattr">
     <mid>
         <inner>
         <inner>
     </mid>
  </outer>
</xml>

something like this...
foundnode = closest(node, "outer[@thisattr]")

Function closest(node,addr)
' what would go here to find the closest.
'I am thining some sort of do while loop, but don't know
End Function
0
Comment
Question by:KeithMcElroy
2 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 40010990
In vbs, the only thing you can do is find a string, then parse that string as needed or move on.  If you are reading rows, use instr function to find the first occurrence of </inner> then new line starting with <inner>

Otherwise, javascript would be a better fit.  If this is for an asp page, you can run javascript server side (jscript) but it would be a lot faster to just do it clientside.
0
 

Author Comment

by:KeithMcElroy
ID: 40011930
so i can't use the xmldom?  I know some about the xmldom, but am stuck on how to use it to bubble up and find the first instance.  I was hoping someone might know how to write a loop that would stop when it finds the matching node.  Will give it a day in case any answers come in; if not will award points.  The jscript idea might help.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now