Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting data from an XML file 1

Status
Not open for further replies.

PPettit

IS-IT--Management
Sep 13, 2003
511
US
I have multiple XML files that I need to check on a daily basis. I have a script that reads the entire file into a string and then it performs some checks using regular expressions. I now need to do another check on the following line:
Code:
<Company:WorkSite>(worksite data)</Company:WorkSite>
What I want to do is take just the (worksite data) info and turn that into a string. I'm having some difficulty figuring out how to do that because the data is of variable length and may contain any combination of letters, numbers, punctuation, and blank spaces.

Does anyone have a suggestion as to how I can accomplish this?
 
have a look at the at the

Set xmlDoc = CreateObject("Microsoft.xmlDOM")
xmlDoc.Load("c:\test.xml")
xmlDoc.async=false
Set Application = xmlDoc.DocumentElement

Application.SelectNodes(.....) you want the string to the node type you are after

or you can just loop through the node

For Each aNode In Application.ChildNodes
aNode.Name, .Text, .NodeName
Next
 
Thanks for the response. I've been taking some time off otherwise I would have replied sooner.

I'm having some trouble making your suggestion work for me. I'm not sure where the problem is. I'm going to have to read up on the Microsoft.xmlDOM stuff. I didn't even know it existed until I read your post. I've been treating my XML files like plain text files all this time.


 
Ok. I've made some progress. Using the code below, I can extract just the text I wanted.
Code:
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("x:\test\test01.xml")
Application = xmlDoc.GetElementsByTagName("Company:WorkSite").item(0).text
wscript.echo application  'this is just so I can make sure I'm getting what I'm looking for
Now I just need to figure out how to work it into my existing script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top