|
-
Jul 24th, 2012, 02:14 PM
#1
Thread Starter
New Member
VBScript with XML
I am trying to gather a piece of data from an XML file and am getting all sorts of errors. Here is my function to grab the piece I need. I just need one piece from the XML and that is "diagCd". I am getting errors saying object required on the Set Node line and then I'm getting "expected '='" on the Set xmlDoc line when I separate it out. I am just trying to read the XML and save diagCd to the variable DX1.
Code:
Function DX1ToUnet(DX1, sUser, FileExists, CurrentVersion)
Set objXMLDoc = Createobject("Microsoft.XMLDOM")
Dim Node
'objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.load("C:\Documents and Settings\" & sUser & "\Local Settings\Application Data\" & CurrentVersion & "\temp.xml")
objXMLDoc.load("temp.xml")
Set Node = objXMLDoc.documentElement.selectSingleNode("diagCd")
DX1 = Node.Text
msgbox DX1
End Function
-
Jul 24th, 2012, 02:26 PM
#2
Re: VBScript with XML
I have to confess that I have absolutely no idea what you're trying to do here and none of it seems to be related to gathering a piece of data from an XML files . Can you explain what you think the code is going to do?
-
Jul 24th, 2012, 02:37 PM
#3
Thread Starter
New Member
Re: VBScript with XML
I am loading the xml doc from:
C:\Documents and Settings\" & sUser & "\Local Settings\Application Data\" & CurrentVersion & "\temp.xml
and reading the node "diagCd" to save to variable DX1. However VBScript doesn't like it. See errors above.
-
Jul 24th, 2012, 03:56 PM
#4
Re: VBScript with XML
Why are you using Microsoft.XMLDOM ? Did you copy that code from somewhere ? There are better facilities in the .Net Framework for handling XML. Two of which are the XmlDocument class and the XDocument class.
EDIT:
What a minute.....is that VB6 code(there is no Set in VB.Net) ? If it is, its in the wrong section of the forum.
-
Jul 24th, 2012, 04:01 PM
#5
Re: VBScript with XML
This needs moved to the ASP VB Script section of the boards.
The sample xml file I was working with.
Code:
<?xml version="1.0" encoding="utf-8"?>
<Root>
<diagcd>Hello World</diagcd>
</Root>
The vbs file I test with.
Code:
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.load "C:\Temp\MyFile.xml"
Set node = xmlDoc.selectsinglenode("//Root/diagcd")
msgbox node.Text
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
-
Jul 24th, 2012, 05:27 PM
#6
Re: VBScript with XML
Thread moved to the ASP, VB Script Forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|