Home > Archive > ASP > March 2008 > Assessing XML Data
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Assessing XML Data
|
|
|
| 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
| |
| Bob Barrows [MVP] 2008-03-23, 9:57 pm |
| J-P-W wrote:
> 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
--
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"
| |
| Anthony Jones 2008-03-24, 6:56 pm |
| "J-P-W" <jonpwebb@gmail.com> wrote in message
news:1e3cd1fc-e166-4a87-b671-b0e5aa1afc07@e23g2000prf.googlegroups.com...
> 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)
%>
--
Anthony Jones - MVP ASP/ASP.NET
| |
|
| On 24 Mar, 17:15, "Anthony Jones" <A...@yadayadayada.com> wrote:
> "J-P-W" <jonpw...@gmail.com> wrote in message
>
> news:1e3cd1fc-e166-4a87-b671-b0e5aa1afc07@e23g2000prf.googlegroups.com...
>
>
>
>
>
>
map.com[color=darkred]
>
>
>
>
>
>
>
>
> Its a little unclear where your GET or POST is originationg from. =A0You s=
ay
> 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. =A0However 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. =A0Also the fact t=
hat
> 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 =3D ""
>
> sValues =3D sValues & "field1=3D" & Server.URLEncode(field1) & ";"
> sValues =3D sValues & "field2=3D" & Server.URLEncoded(field2) & ";"
>
> Dim xhr: Set xhr =3D 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 =3D 200 Then
> =A0 =A0 Dim node : Set nodeID =3D Nothing
> =A0 =A0 Set node =3D xhr.ResponseXML("/results/submission[@response=3D'OK'=
]/@id)
> =A0 =A0 If Not node Is Nothing Then
> =A0 =A0 =A0 =A0 PostValues =3D node.Text
> =A0 =A0 Else
> =A0 =A0 =A0 =A0 Dim sError: sError =3D ""
> =A0 =A0 =A0 =A0 For Each node In xhr.ResponseXML("/results/error")
> =A0 =A0 =A0 =A0 =A0 =A0 sError =3D sError & node.getAttribute("fieldname")=
& " is " & _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 node.getAttribute("type") & vbCrLf
> =A0 =A0 =A0 =A0 Next
> =A0 =A0 =A0 =A0 Error.Raise 1001, "PostValues", sError
> =A0 =A0 End If
> Else
> =A0 =A0 Error.Raise 1002, "PostValues", xhr.statusText
> End If
>
> End Function
>
> sID =3D PostValue(rs("field1").Value, rs("field2").value)
>
> %>
>
> --
> Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
>
> - Show quoted text -
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
| |
| Anthony Jones 2008-03-24, 6:56 pm |
| "J-P-W" <jonpwebb@gmail.com> wrote in message
news:6338e0ad-56ac-4dda-9c1a-8653d8d55b50@e10g2000prf.googlegroups.com...
On 24 Mar, 17:15, "Anthony Jones" <A...@yadayadayada.com> wrote:[color=darkred]
> "J-P-W" <jonpw...@gmail.com> wrote in message
>
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.
--
Anthony Jones - MVP ASP/ASP.NET
|
|
|
|
|