Hi, I am going nuts with this. Can you help me write a code to parse this
XML document. I need to get values from all the tags and assign them into
variables. See code below. The code is in VBScript.

Many thanks,
Roger.

<%
option explicit
response.expires = 0
Response.CacheControl = "no-cache"
response.buffer = true
Response.ContentType = "text/html"

Dim xmlString

xmlString = "<?xml version=""1.0""?>" & _
"<ResponseService Version=""2.3"">" & _
" <Header>" & _
" <Partner>UserName</Partner>" & _
" <Password>Password</Password>" & _
" <ServiceID>1</ServiceID>" & _
" </Header>" & _
" <ResponseList>" & _
" <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">" & _
" <TransactionID>215980</TransactionID>" & _
" <OriginatingNumber>447900000000</OriginatingNumber>" & _
" <Time>200412181427</Time>" & _
" <Data>This is a message.</Data>" & _
" <Deliverer>1</Deliverer>" & _
" <Destination>12345</Destination>" & _
" <Operator>99999</Operator>" & _
" <Tariff>150</Tariff>" & _
" <SessionId>SessionID</SessionId>" & _
" <Tags>" & _
" <Tag Name=""Number"">12</Tag>" & _
" <Tag Name=""City"">Rome</Tag>" & _
" </Tags>" & _
" </Response>" & _
" </ResponseList>" & _
"</ResponseService>"


Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
Set XMLDoc = Server.CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
XMLDoc.loadXML(xmlString)
Set rootNode = XMLDoc.documentElement


Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber, Time,
Data
Dim Deliverer, Destination, Operator, Tariff, SessionId, Number, City


'CAN YOU HELP ME WITH THE CODE TO PARSE VALUES FROM THE ABOVE XML DOCUMENT
AND ASSIGN THEM TO THE VARIABLES BELOW?


Partner =
Password =
ServiceID =
TransactionID =
OriginatingNumber =
Time =
Data =
Deliverer =
Destination =
Operator =
Tariff =
SessionId =
Number =
City =

Re: Need help with parsing XML values to variables. Using VBScript by Bob

Bob
Mon Jul 17 08:02:25 CDT 2006

Roger Jones wrote:
> Hi, I am going nuts with this. Can you help me write a code to parse
> this XML document. I need to get values from all the tags and assign
> them into variables. See code below. The code is in VBScript.
>
> Many thanks,
> Roger.
>
> <%
> option explicit
> response.expires = 0
> Response.CacheControl = "no-cache"
> response.buffer = true
> Response.ContentType = "text/html"
>
> Dim xmlString
>
> xmlString = "<?xml version=""1.0""?>" & _
> "<ResponseService Version=""2.3"">" & _
> " <Header>" & _
> " <Partner>UserName</Partner>" & _
> " <Password>Password</Password>" & _
> " <ServiceID>1</ServiceID>" & _
> " </Header>" & _
> " <ResponseList>" & _
> " <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">" & _
> " <TransactionID>215980</TransactionID>" & _
> " <OriginatingNumber>447900000000</OriginatingNumber>" & _
> " <Time>200412181427</Time>" & _
> " <Data>This is a message.</Data>" & _
> " <Deliverer>1</Deliverer>" & _
> " <Destination>12345</Destination>" & _
> " <Operator>99999</Operator>" & _
> " <Tariff>150</Tariff>" & _
> " <SessionId>SessionID</SessionId>" & _
> " <Tags>" & _
> " <Tag Name=""Number"">12</Tag>" & _
> " <Tag Name=""City"">Rome</Tag>" & _
> " </Tags>" & _
> " </Response>" & _
> " </ResponseList>" & _
> "</ResponseService>"
>
>
> Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
> Set XMLDoc = Server.CreateObject("Microsoft.XMLDOM")
> XMLDoc.async = False
> XMLDoc.loadXML(xmlString)
> Set rootNode = XMLDoc.documentElement
>
>
> Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber,
> Time, Data
> Dim Deliverer, Destination, Operator, Tariff, SessionId, Number, City
>
>
> 'CAN YOU HELP ME WITH THE CODE TO PARSE VALUES FROM THE ABOVE XML
> DOCUMENT AND ASSIGN THEM TO THE VARIABLES BELOW?
>
>
This should get you going:
Partner =xmldoc.selectSingleNode("ResponseService/" & _
"Header/Partner").text

The rest are similar except for these two which are a little more
complicated:
Number =xmldoc.selectSingleNode("ResponseService/" & _
"ResponseList/Tags/Tag[@Name='Number']").text
City=xmldoc.selectSingleNode("ResponseService/" & _
"ResponseList/Tags/Tag[@Name='City']").text


Just be aware that everything is case-sensitive
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Need help with parsing XML values to variables. Using VBScript by Roger

Roger
Mon Jul 17 14:01:07 CDT 2006

Hi Bob,

I've tried it, but it does not want to work for me.

Roger


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:u0z7AFaqGHA.2440@TK2MSFTNGP03.phx.gbl...
> Roger Jones wrote:
> > Hi, I am going nuts with this. Can you help me write a code to parse
> > this XML document. I need to get values from all the tags and assign
> > them into variables. See code below. The code is in VBScript.
> >
> > Many thanks,
> > Roger.
> >
> > <%
> > option explicit
> > response.expires = 0
> > Response.CacheControl = "no-cache"
> > response.buffer = true
> > Response.ContentType = "text/html"
> >
> > Dim xmlString
> >
> > xmlString = "<?xml version=""1.0""?>" & _
> > "<ResponseService Version=""2.3"">" & _
> > " <Header>" & _
> > " <Partner>UserName</Partner>" & _
> > " <Password>Password</Password>" & _
> > " <ServiceID>1</ServiceID>" & _
> > " </Header>" & _
> > " <ResponseList>" & _
> > " <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">" & _
> > " <TransactionID>215980</TransactionID>" & _
> > " <OriginatingNumber>447900000000</OriginatingNumber>" & _
> > " <Time>200412181427</Time>" & _
> > " <Data>This is a message.</Data>" & _
> > " <Deliverer>1</Deliverer>" & _
> > " <Destination>12345</Destination>" & _
> > " <Operator>99999</Operator>" & _
> > " <Tariff>150</Tariff>" & _
> > " <SessionId>SessionID</SessionId>" & _
> > " <Tags>" & _
> > " <Tag Name=""Number"">12</Tag>" & _
> > " <Tag Name=""City"">Rome</Tag>" & _
> > " </Tags>" & _
> > " </Response>" & _
> > " </ResponseList>" & _
> > "</ResponseService>"
> >
> >
> > Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
> > Set XMLDoc = Server.CreateObject("Microsoft.XMLDOM")
> > XMLDoc.async = False
> > XMLDoc.loadXML(xmlString)
> > Set rootNode = XMLDoc.documentElement
> >
> >
> > Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber,
> > Time, Data
> > Dim Deliverer, Destination, Operator, Tariff, SessionId, Number, City
> >
> >
> > 'CAN YOU HELP ME WITH THE CODE TO PARSE VALUES FROM THE ABOVE XML
> > DOCUMENT AND ASSIGN THEM TO THE VARIABLES BELOW?
> >
> >
> This should get you going:
> Partner =xmldoc.selectSingleNode("ResponseService/" & _
> "Header/Partner").text
>
> The rest are similar except for these two which are a little more
> complicated:
> Number =xmldoc.selectSingleNode("ResponseService/" & _
> "ResponseList/Tags/Tag[@Name='Number']").text
> City=xmldoc.selectSingleNode("ResponseService/" & _
> "ResponseList/Tags/Tag[@Name='City']").text
>
>
> Just be aware that everything is case-sensitive
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>



Re: Need help with parsing XML values to variables. Using VBScript by Bob

Bob
Mon Jul 17 15:03:28 CDT 2006

Sorry about that.

If you want more than sympathy, you'll need to show us what you tried
and the results you obtained (including any error messages).

Roger Jones wrote:
> Hi Bob,
>
> I've tried it, but it does not want to work for me.
>
> Roger
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:u0z7AFaqGHA.2440@TK2MSFTNGP03.phx.gbl...
>> Roger Jones wrote:
>>> Hi, I am going nuts with this. Can you help me write a code to parse
>>> this XML document. I need to get values from all the tags and assign
>>> them into variables. See code below. The code is in VBScript.
>>>
>>> Many thanks,
>>> Roger.
>>>
>>> <%
>>> option explicit
>>> response.expires = 0
>>> Response.CacheControl = "no-cache"
>>> response.buffer = true
>>> Response.ContentType = "text/html"
>>>
>>> Dim xmlString
>>>
>>> xmlString = "<?xml version=""1.0""?>" & _
>>> "<ResponseService Version=""2.3"">" & _
>>> " <Header>" & _
>>> " <Partner>UserName</Partner>" & _
>>> " <Password>Password</Password>" & _
>>> " <ServiceID>1</ServiceID>" & _
>>> " </Header>" & _
>>> " <ResponseList>" & _
>>> " <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">"
>>> & _ " <TransactionID>215980</TransactionID>" & _
>>> " <OriginatingNumber>447900000000</OriginatingNumber>" & _
>>> " <Time>200412181427</Time>" & _
>>> " <Data>This is a message.</Data>" & _
>>> " <Deliverer>1</Deliverer>" & _
>>> " <Destination>12345</Destination>" & _
>>> " <Operator>99999</Operator>" & _
>>> " <Tariff>150</Tariff>" & _
>>> " <SessionId>SessionID</SessionId>" & _
>>> " <Tags>" & _
>>> " <Tag Name=""Number"">12</Tag>" & _
>>> " <Tag Name=""City"">Rome</Tag>" & _
>>> " </Tags>" & _
>>> " </Response>" & _
>>> " </ResponseList>" & _
>>> "</ResponseService>"
>>>
>>>
>>> Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
>>> Set XMLDoc = Server.CreateObject("Microsoft.XMLDOM")
>>> XMLDoc.async = False
>>> XMLDoc.loadXML(xmlString)
>>> Set rootNode = XMLDoc.documentElement
>>>
>>>
>>> Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber,
>>> Time, Data
>>> Dim Deliverer, Destination, Operator, Tariff, SessionId, Number,
>>> City
>>>
>>>
>>> 'CAN YOU HELP ME WITH THE CODE TO PARSE VALUES FROM THE ABOVE XML
>>> DOCUMENT AND ASSIGN THEM TO THE VARIABLES BELOW?
>>>
>>>
>> This should get you going:
>> Partner =xmldoc.selectSingleNode("ResponseService/" & _
>> "Header/Partner").text
>>
>> The rest are similar except for these two which are a little more
>> complicated:
>> Number =xmldoc.selectSingleNode("ResponseService/" & _
>> "ResponseList/Tags/Tag[@Name='Number']").text
>> City=xmldoc.selectSingleNode("ResponseService/" & _
>> "ResponseList/Tags/Tag[@Name='City']").text
>>
>>
>> Just be aware that everything is case-sensitive
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so
>> I don't check it very often. If you must reply off-line, then remove
>> the "NO SPAM"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Need help with parsing XML values to variables. Using VBScript by Bob

Bob
Mon Jul 17 15:18:04 CDT 2006

Roger Jones wrote:
> Hi Bob,
>
> I've tried it, but it does not want to work for me.
>
> Roger
>
I did make a mistake in the xpaths for number and city: I failed to
incorporate the Response node into the path. The following is tested:


<%
option explicit
response.expires = 0
Response.CacheControl = "no-cache"
response.buffer = true
Response.ContentType = "text/html"

Dim xmlString

xmlString = "<?xml version=""1.0""?>" & _
"<ResponseService Version=""2.3"">" & _
" <Header>" & _
" <Partner>UserName</Partner>" & _
" <Password>Password</Password>" & _
" <ServiceID>1</ServiceID>" & _
" </Header>" & _
" <ResponseList>" & _
" <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">" & _
" <TransactionID>215980</TransactionID>" & _
" <OriginatingNumber>447900000000</OriginatingNumber>" & _
" <Time>200412181427</Time>" & _
" <Data>This is a message.</Data>" & _
" <Deliverer>1</Deliverer>" & _
" <Destination>12345</Destination>" & _
" <Operator>99999</Operator>" & _
" <Tariff>150</Tariff>" & _
" <SessionId>SessionID</SessionId>" & _
" <Tags>" & _
" <Tag Name=""Number"">12</Tag>" & _
" <Tag Name=""City"">Rome</Tag>" & _
" </Tags>" & _
" </Response>" & _
" </ResponseList>" & _
"</ResponseService>"


Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
Set XMLDoc = Server.CreateObject("msxml2.domdocument")
XMLDoc.async = False
XMLDoc.loadXML(xmlString)
Set rootNode = XMLDoc.documentElement
'XMLDoc.save Response
'response.End

Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber,
Time,Data
Dim Deliverer, Destination, Operator, Tariff, SessionId, Number, City
dim node
set node = nothing
set node = XMLDoc.selectSingleNode("ResponseService/" & _
"Header/Partner")
if not node is nothing then
Partner =node.text
Response.Write "Partner: " & Partner & "<BR>"
else
Response.Write "Something wrong with the Partner xpath"
end if

set node = nothing
set node = XMLDoc.selectSingleNode("ResponseService/" & _
"ResponseList/Response/Tags/Tag[@Name='Number']")
if not node is nothing then
Number =node.text
Response.Write "Number: " & Number & "<BR>"
else
Response.Write "Something wrong with the Number xpath" & "<BR>"
end if
set node = nothing
set node = XMLDoc.selectSingleNode("ResponseService/" & _
"ResponseList/Response/Tags/Tag[@Name='City']")
if not node is nothing then
City =node.text
Response.Write "City: " & City & "<BR>"
else
Response.Write "Something wrong with the City xpath" & "<BR>"
end if

%>


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Need help with parsing XML values to variables. Using VBScript by Roger

Roger
Mon Jul 17 17:36:50 CDT 2006

You are so....good looking...:) (Seinfeld)....Hey!!!! IT WORKS GREAT!!!
THANK YOU SO MUCH!!!!

Roger.

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:eQp4e4dqGHA.5108@TK2MSFTNGP05.phx.gbl...
> Roger Jones wrote:
> > Hi Bob,
> >
> > I've tried it, but it does not want to work for me.
> >
> > Roger
> >
> I did make a mistake in the xpaths for number and city: I failed to
> incorporate the Response node into the path. The following is tested:
>
>
> <%
> option explicit
> response.expires = 0
> Response.CacheControl = "no-cache"
> response.buffer = true
> Response.ContentType = "text/html"
>
> Dim xmlString
>
> xmlString = "<?xml version=""1.0""?>" & _
> "<ResponseService Version=""2.3"">" & _
> " <Header>" & _
> " <Partner>UserName</Partner>" & _
> " <Password>Password</Password>" & _
> " <ServiceID>1</ServiceID>" & _
> " </Header>" & _
> " <ResponseList>" & _
> " <Response SequenceNumber=""1"" Type=""ALA"" Format=""Text"">" & _
> " <TransactionID>215980</TransactionID>" & _
> " <OriginatingNumber>447900000000</OriginatingNumber>" & _
> " <Time>200412181427</Time>" & _
> " <Data>This is a message.</Data>" & _
> " <Deliverer>1</Deliverer>" & _
> " <Destination>12345</Destination>" & _
> " <Operator>99999</Operator>" & _
> " <Tariff>150</Tariff>" & _
> " <SessionId>SessionID</SessionId>" & _
> " <Tags>" & _
> " <Tag Name=""Number"">12</Tag>" & _
> " <Tag Name=""City"">Rome</Tag>" & _
> " </Tags>" & _
> " </Response>" & _
> " </ResponseList>" & _
> "</ResponseService>"
>
>
> Dim XMLDoc, rootNode, Header, item, i, strSnowHeight, ResponseList
> Set XMLDoc = Server.CreateObject("msxml2.domdocument")
> XMLDoc.async = False
> XMLDoc.loadXML(xmlString)
> Set rootNode = XMLDoc.documentElement
> 'XMLDoc.save Response
> 'response.End
>
> Dim Partner, Password, ServiceID, TransactionID, OriginatingNumber,
> Time,Data
> Dim Deliverer, Destination, Operator, Tariff, SessionId, Number, City
> dim node
> set node = nothing
> set node = XMLDoc.selectSingleNode("ResponseService/" & _
> "Header/Partner")
> if not node is nothing then
> Partner =node.text
> Response.Write "Partner: " & Partner & "<BR>"
> else
> Response.Write "Something wrong with the Partner xpath"
> end if
>
> set node = nothing
> set node = XMLDoc.selectSingleNode("ResponseService/" & _
> "ResponseList/Response/Tags/Tag[@Name='Number']")
> if not node is nothing then
> Number =node.text
> Response.Write "Number: " & Number & "<BR>"
> else
> Response.Write "Something wrong with the Number xpath" & "<BR>"
> end if
> set node = nothing
> set node = XMLDoc.selectSingleNode("ResponseService/" & _
> "ResponseList/Response/Tags/Tag[@Name='City']")
> if not node is nothing then
> City =node.text
> Response.Write "City: " & City & "<BR>"
> else
> Response.Write "Something wrong with the City xpath" & "<BR>"
> end if
>
> %>
>
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>