Assessing XML Data

J

J-P-W

Hi,

I'm using a form to go submit data to a third party web site http://ononemap.com
at "http://ononemap.com/lib/ajx/api". The contents of the form are
hidden form fields [populated from my database], the data will have
been validated.

If I successfully submit the data (I can use get or post) I get
something like:

- <results requestedaction="add">
<submission response="OK" id="123456789" />
</results>

Can anyone assist? I need to 'receive' the reslutlant XML data and
store the id into my database. If I had something like
request.querystring("id") or request.form("id") I'd be more than
happy, but this information is surely just displayed on the page that
I post to!

Maybe I'm a little dim here but I just can't figure how to retreive
that info.

If there is a failure I'd get somthing like:

<results requestedaction="add">
<error type="incomplete" fieldname="title" />
<error type="invalid" fieldname="price" />
<error type="invalid" fieldname="imgurl" />
</results>

I could do with retrieving that data also!

Thanks

Jon
 
B

Bob Barrows [MVP]

J-P-W said:
Hi,

I'm using a form to go submit data to a third party web site
http://ononemap.com at "http://ononemap.com/lib/ajx/api". The
contents of the form are
hidden form fields [populated from my database], the data will have
been validated.

If I successfully submit the data (I can use get or post) I get
something like:

- <results requestedaction="add">
<submission response="OK" id="123456789" />
</results>

Can anyone assist? I need to 'receive' the reslutlant XML data and
store the id into my database. If I had something like
request.querystring("id") or request.form("id") I'd be more than
happy, but this information is surely just displayed on the page that
I post to!

Maybe I'm a little dim here but I just can't figure how to retreive
that info.

If there is a failure I'd get somthing like:

<results requestedaction="add">
<error type="incomplete" fieldname="title" />
<error type="invalid" fieldname="price" />
<error type="invalid" fieldname="imgurl" />
</results>

I could do with retrieving that data also!
http://www.aspfaq.com/show.asp?id=2173
 
A

Anthony Jones

J-P-W said:
Hi,

I'm using a form to go submit data to a third party web site http://ononemap.com
at "http://ononemap.com/lib/ajx/api". The contents of the form are
hidden form fields [populated from my database], the data will have
been validated.

If I successfully submit the data (I can use get or post) I get
something like:

- <results requestedaction="add">
<submission response="OK" id="123456789" />
</results>

Can anyone assist? I need to 'receive' the reslutlant XML data and
store the id into my database. If I had something like
request.querystring("id") or request.form("id") I'd be more than
happy, but this information is surely just displayed on the page that
I post to!

Maybe I'm a little dim here but I just can't figure how to retreive
that info.

If there is a failure I'd get somthing like:

<results requestedaction="add">
<error type="incomplete" fieldname="title" />
<error type="invalid" fieldname="price" />
<error type="invalid" fieldname="imgurl" />
</results>

I could do with retrieving that data also!

Its a little unclear where your GET or POST is originationg from. You say
that the field values are provided from a Database so that would suggest
server-side code in ASP making a request to a third party. However you make
no mention of what it is that you are using to make that request (which
typically would be the MSXMLs ServerXMLHTTP object) and this leads me to
wonder if the request originates from a client browser. Also the fact that
you refer to the fields as being hidden points to this being clientside.

It sounds like you should be doing all this serverside.

<%

Function PostValues(field1, field2)

Dim sValues : sValues = ""

sValues = sValues & "field1=" & Server.URLEncode(field1) & ";"
sValues = sValues & "field2=" & Server.URLEncoded(field2) & ";"


Dim xhr: Set xhr = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xhr.Open "POST", "http://ononemap.com/lib/ajx/api", False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.Send sValues
If xhr.Status = 200 Then
Dim node : Set nodeID = Nothing
Set node = xhr.ResponseXML("/results/submission[@response='OK']/@id)
If Not node Is Nothing Then
PostValues = node.Text
Else
Dim sError: sError = ""
For Each node In xhr.ResponseXML("/results/error")
sError = sError & node.getAttribute("fieldname") & " is " & _
node.getAttribute("type") & vbCrLf
Next
Error.Raise 1001, "PostValues", sError
End If
Else
Error.Raise 1002, "PostValues", xhr.statusText
End If

End Function


sID = PostValue(rs("field1").Value, rs("field2").value)


%>
 
J

J-P-W

I'm using a form to go submit data to a third party web sitehttp://ononemap.com
at "http://ononemap.com/lib/ajx/api". The contents of the form are
hidden form fields [populated from my database], the data will have
been validated.
If I successfully submit the data (I can use get or post) I get
something like:
- <results requestedaction="add">
  <submission response="OK" id="123456789" />
  </results>
Can anyone assist? I need to 'receive' the reslutlant XML data and
store the id into my database. If I had something like
request.querystring("id") or request.form("id") I'd be more than
happy, but this information is surely just displayed on the page that
I post to!
Maybe I'm a little dim here but I just can't figure how to retreive
that info.
If there is a failure I'd get somthing like:
<results requestedaction="add">
<error type="incomplete" fieldname="title" />
<error type="invalid" fieldname="price" />
<error type="invalid" fieldname="imgurl" />
</results>
I could do with retrieving that data also!

Its a little unclear where your GET or POST is originationg from.  You say
that the field values are provided from a Database so that would suggest
server-side code in ASP making a request to a third party.  However you make
no mention of what it is that you are using to make that request (which
typically would be the MSXMLs ServerXMLHTTP object) and this leads me to
wonder if the request originates from a client browser.  Also the fact that
you refer to the fields as being hidden points to this being clientside.

It sounds like you should be doing all this serverside.

<%

Function PostValues(field1, field2)

Dim sValues : sValues = ""

sValues = sValues & "field1=" & Server.URLEncode(field1) & ";"
sValues = sValues & "field2=" & Server.URLEncoded(field2) & ";"

Dim xhr: Set xhr = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xhr.Open "POST", "http://ononemap.com/lib/ajx/api", False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.Send sValues
If xhr.Status = 200 Then
    Dim node : Set nodeID = Nothing
    Set node = xhr.ResponseXML("/results/submission[@response='OK']/@id)
    If Not node Is Nothing Then
        PostValues = node.Text
    Else
        Dim sError: sError = ""
        For Each node In xhr.ResponseXML("/results/error")
            sError = sError & node.getAttribute("fieldname")& " is " & _
                node.getAttribute("type") & vbCrLf
        Next
        Error.Raise 1001, "PostValues", sError
    End If
Else
    Error.Raise 1002, "PostValues", xhr.statusText
End If

End Function

sID = PostValue(rs("field1").Value, rs("field2").value)

%>

Thank you so far!

So far a have a form within an ASP page. The form elements are all
hidden values, those values being loaded from a database. The user has
a 'Submit this property to oneonmao.com' sort of button.

I guess what I need is not a form post but a function to post the
data, then analyse the data received. To be honest this is not
something I've tried before, so I'm off to practice....

Regards

Jon
 
A

Anthony Jones

So far a have a form within an ASP page. The form elements are all
hidden values, those values being loaded from a database. The user has
a 'Submit this property to oneonmao.com' sort of button.

I guess what I need is not a form post but a function to post the
data, then analyse the data received. To be honest this is not
something I've tried before, so I'm off to practice....
<<<<

A function on server to post the data?
You can just extend the example I posted to include the set of fields you
are using.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top