List Info

Thread: Re: ASP.NET and Upcoming API




Re: ASP.NET and Upcoming API
user name
2007-10-10 13:38:45

THANK YOU VERY MUCH FOR YOUR HELP!!!!

This worked --> XmlResult.SelectNodes("//venue")
I didn't have // in front of venue.
Things like this can make a programmer want to smash something.



If anyone needs an asp.net solution to UPCOMING let me know.. It
should be complete in the next day or so.

--- In yws-events%40yahoogroups.com">yws-eventsyahoogroups.com, "Yoan BLANC"; <greutpompage...>
wrote:
>
&gt; --- In yws-events%40yahoogroups.com">yws-eventsyahoogroups.com, "stewsterl" <stewsterl> wrote:
&gt; >
>; > Wow! Thanks for the quick reply.
> > I did change my POST request to a GET.
> > My issue is in parsing the xml. I get a valid xml response.
> > XmlResult.LoadXml(strResult)
> > I get the same valid response as if I entered it in a web
browser.
> > So my issue is parsing that results. Mainly Here-->
> >
> > Dim bodyAttrib As System.Xml.XmlNodeList = XmlResult.SelectNodes
> > ("/rsp/event&quot;)
>
> SelectNodes is an XPath query, simply do "//event" (on
*DocumentElement*).
>
> Dim events As System.Xml.XmlNodeList =
> XmlResult.DocumentElement.SelectNodes(&quot;//event&quot;)
&gt;
> >
> >
> > For Each attr As XmlNode In bodyAttrib
>
> For Each event As XmlNode In events
&gt;
> Dim name as string = event.Attributes.GetNamedItem("name&quot;).Value;
> Dim description as string =
> event.Attributes.GetNamedItem("description";).Value;
>
> This should work from my point of view, did you test for an error ?
> (It's always good to test your URL in a browser directly (or curl,
&gt; forget that you're obviously on Windows).
>
> I know pretty nothing in VB.NET (except RTFM).
&gt;
> Best of luck,
&gt;
> > Dim name As XmlAttribute = DirectCast
(attr.Attributes.GetNamedItem
> > ("name"), XmlAttribute)
> > Dim val As XmlAttribute = DirectCast
(attr.Attributes.GetNamedItem
> > ("description&quot;), XmlAttribute)
> > If name IsNot Nothing AndAlso val IsNot Nothing Then
>; > TextBox1.Text = name.Value & val.Value
> > End If
> > Next
>; >
> > --- In yws-events%40yahoogroups.com">yws-eventsyahoogroups.com, Gordon Luk <gluk> wrote:
&gt; > >
>; > > Also, it looks like you're using a POST request to do a GET
query.
> > That
> > > may be returning an error instead of event objects, so that
could
> > be
> > > getting in your way. Take a look at the actual URL and try
pasting
> > it in
> > > a browser. Also, you can try printing out the returned XML as
> > plaintext
> > > to help in your debugging, to make sure the problem isn't
before
> > your
> > > query call. If you're using XPath (not sure, i'm not a .Net
guy),
> > you
> > > may want to try /rsp/event. The advantage of building a REST-
like
> > API is
> > > that we usually print out helpful error messages on the way.
>; > >
> > > stewsterl wrote:
&gt; > > >
> > > >
> > > > I'm currently working on an ASP.NET site that needs to use
the
&gt; > > > Upcoming API.
>; > > >
> > > > I have the following code to get the returned XML:
>; > > >
> > > > Dim url As String
> > = "http://upcoming.yahooapis.com/services/rest/?
> > > > <http://upcoming.yahooapis.com/services/rest/?>
> > > > method=venue.search&amp;location=Troy,3;MI&api_key=<Your Key>&quot;
> > > >
> > > > Dim RequestXMLstring As String = "<?xml version='1.0'?
>; > > > ><element1>Some Value</element1>;"
> > > > Dim XmlResult As New System.Xml.XmlDocument
> > > > Dim anXMLhttpObject As Object
&gt; > > > anXMLhttpObject = Server.CreateObject("MSXML2.ServerXMLHTTP")
> > > >
> > > > Try
> > > > anXMLhttpObject.open("POST", url, False)
&gt; > > > Catch
&gt; > > > Response.Write(";Connection cannot be established. Please
&gt; > > > try again later.&quot;)
> > > > End Try
> > > >
> > > > anXMLhttpObject.setRequestHeader("Content-
&gt; > > > Type", "application/x-www-form-urlencoded&quot;)
&gt; > > >
> > > > anXMLhttpObject.setRequestHeader("Content-Length", Len
> > > > (RequestXMLstring))
> > > >
> > > > anXMLhttpObject.send(RequestXMLstring)
> > > >
> > > > Dim strResult As String = anXMLhttpObject.responseText
> > > >
> > > > XmlResult.LoadXml(strResult)
> > > >
> > > > '***************************************
> > > >
> > > > Dim bodyAttrib As System.Xml.XmlNodeList =
> > > > XmlResult.SelectNodes("rsp/")
> > > >
> > > > For Each attr As XmlNode In bodyAttrib
> > > > Dim name As XmlAttribute = DirectCast
> > > > (attr.Attributes.GetNamedItem("name&quot;), XmlAttribute)
> > > > Dim val As XmlAttribute = DirectCast
> > > > (attr.Attributes.GetNamedItem("description";), XmlAttribute)
> > > > If name IsNot Nothing AndAlso val IsNot Nothing Then
>; > > > TextBox1.Text = name.Value & val.Value
> > > > End If
> > > > Next
>; > > >
> > > > I get the results just fine. I'm having a little trouble
parsing
> > the
> > > > xml here -->XmlResult.SelectNodes(&quot;rsp/&quot;)
> > > > I've tried: XmlResult.SelectNodes("rsp/event";)
> > > > No luck.. Anyone have any ideas?
&gt; > > >
> > > > Thank you in advance..
> > > >
> > > >
>; > >
>; >
>;

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )