?
Solved

Store XML in String in access database by tag name

Posted on 2003-03-18
6
Medium Priority
?
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

765 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