Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Store XML in String in access database by tag name

Posted on 2003-03-18
6
Medium Priority
?
351 Views
Last Modified: 2013-11-19
I am trying to store XML from a string in an access database.  I have some code pasted below:

<% Dim xmlrequest
set xmlrequest = server.CreateObject("MSXML2.ServerXMLHTTP")
   
xmlrequest.open "post", "http://awebaddress/xml/xml.axp", False
xmlrequest.setRequestHeader "content-type", "text/xml"

xmlrequest.send XMLstring
%>

After posting my ASP code I am trying to store the response:

<%=xmlrequest.responsetext%>

The value of which is:
<?xml version="1.0"?>
<SMSRequest>
<XMLRequestorVersion></XMLRequestorVersion>
<Userid><![CDATA[aaa@aaa.co.uk]]></Userid>
<Password>aaaaaa</Password>
<RequestList>
<Request>sendMessage</Request>
<Message>
<softwareversion>Bespoke XML POST</softwareversion>
<Destination>44777555555</Destination>
<MessageType>SMS</MessageType>
<Text><![CDATA[Test Message with GUID filled in]]></Text>
<MessageID>XNSPDHWG2/24/2003 9:58:01 AM</MessageID>
<FormattedDestination>44777555555</FormattedDestination>
<guid>1</guid>
<Result>OK</Result>
</Message>
</RequestList>
<Credits>17</Credits>
</SMSRequest>

I have tried to figure out how to do it but am very new to XML.  The code I have tried is:    

<%     Dim xmldoc, strtext
Set xmldoc = CreateObject("MSXML2.DOMDocument")
strtext = xmlrequest.responsetext
xmldoc.loadXML(strtext)
response.write strtext.getelementsbytagname("Description")
%>

For now I am just trying to display on the page rather than save in the database.  I keep getting an error:

Microsoft VBScript runtime (0x800A01A8)
Object required: '<?xml version="1.0"?'
/textclever/sendaction.asp, line 138

Line 138 is the "response.write strtext.getelementsbytagname("Description")" line

Can anyone point me in the correct direction?

Matt
0
Comment
Question by:golfgti108
  • 2
4 Comments
 

Expert Comment

by:WHalphen
ID: 8163281
In line 138 you are using a method, getelementsbytagname, on a variant variable, strtext.  The software is expecting an object reference such as xmldoc.

But, even if you use the getelementsbytagname method on an object, it returns a nodelist and cannot be used with response.write which requires a string argument.

It's not clear what you are trying to do here.  Do you want to display the full xml document?  If so, use response.write strtext

Are you trying to display the value associated with a node?  If so, use a selectsinglenode method to get a node and then use the nodevalue property to get the value into a string variable that can be displayed.

Don't give up! The xml document object model is very powerful and useful.  It's well worth the effort and frustration to learn to use it...

good luck
0
 

Author Comment

by:golfgti108
ID: 8168940
Thanks for your comments.

I am trying to store the 'values' (I may not be using the correct terminology) of <MessageID>, <FormattedDestination>, <guid> and <Result> in an access database with columns named identically to the tags.

In the meantime I was just trying to display the 'values' of the above tags on the page.

You wrote: Are you trying to display the value associated with a node?  If so, use a selectsinglenode method to get a node and then use the nodevalue property to get the value into a string variable that can be displayed.

I think this is what I am saying.  Can you explain how to use the selectsinglenode method, so that I can display the values of the above tags.

Thanks in advance

Alex
0
 
LVL 1

Accepted Solution

by:
dsaddan earned 300 total points
ID: 8170262
<%     Dim xmldoc, strtext
Set xmldoc = CreateObject("MSXML2.DOMDocument")
strtext = xmlrequest.responsetext
xmldoc.loadXML(strtext)
response.write "MessageID=" & xmldoc.selectsinglenode("MessageID").text
%>
0
 

Expert Comment

by:WHalphen
ID: 8170477
The example from dsaddan should work for you.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

571 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