Loading ...
Sorry, an error occurred while loading the content.

How do you use parseXMLData? There are no examples!

Expand Messages
  • Josh Lizarraga
    Hi all. I want to use the DataSource utility to parse some very simple XML data. Here s a sample of the data:
    Message 1 of 4 , Sep 1, 2008
    • 0 Attachment
      Hi all. I want to use the DataSource utility to parse some very simple
      XML data. Here's a sample of the data:

      <results>
      <result
      vin = "PCF168FC9LWIZPY"
      stock = "2DTSZ"
      year = "2008"
      />
      </results>

      Here's what I've got so far with YUI:

      var invData = new
      YAHOO.util.DataSource("http://www.example.com/example_feed.xml");
      invData.responseType = YAHOO.util.DataSource.TYPE_XML;
      invData.responseSchema = {
      resultNode: "result",
      fields: [
      "vin",
      "stock",
      {key: "year", parser: YAHOO.util.DataSource.parseNumber}
      ]
      };
      var invListing = invData.parseXMLData(oRequest,oFullResponse);

      I want to use the parseXMLData function to parse the data, but I don't
      understand what oRequest and oFullResponse are. Can someone please
      explain how these parameters affect my results?

      Thanks a bunch for any help!
    • Satyam
      You should call method sendRequest, that function, depending on the responseType you have declared, will call the right parser for you. See:
      Message 2 of 4 , Sep 1, 2008
      • 0 Attachment
        You should call method sendRequest, that function, depending on the
        responseType you have declared, will call the right parser for you. See:

        http://developer.yahoo.com/yui/datasource/#sendrequest

        Satyam


        Josh Lizarraga wrote:
        > Hi all. I want to use the DataSource utility to parse some very simple
        > XML data. Here's a sample of the data:
        >
        > <results>
        > <result
        > vin = "PCF168FC9LWIZPY"
        > stock = "2DTSZ"
        > year = "2008"
        > />
        > </results>
        >
        > Here's what I've got so far with YUI:
        >
        > var invData = new
        > YAHOO.util.DataSource("http://www.example.com/example_feed.xml");
        > invListing.responseType = YAHOO.util.DataSource.TYPE_XML;
        > invListing.responseSchema = {
        > resultNode: "result",
        > fields: [
        > "vin",
        > "stock",
        > {key: "year", parser: YAHOO.util.DataSource.parseNumber}
        > ]
        > };
        > var invListing = invData.parseXMLData(oRequest,oFullResponse);
        >
        > I want to use the parseXMLData function to parse the data, but I don't
        > understand what oRequest and oFullResponse are. Can someone please
        > explain how these parameters affect my results?
        >
        > Thanks a bunch for any help!
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
      • Josh Lizarraga
        Thank you for your response, but now I have the same problem with sendRequest - I don t know what oResponse is supposed to be in my case. I understand what
        Message 3 of 4 , Sep 1, 2008
        • 0 Attachment
          Thank you for your response, but now I have the same problem with
          sendRequest - I don't know what oResponse is supposed to be in my
          case. I understand what oCallback is/does.

          In the example, oResponse is used to narrow down the results to only
          greyhounds:

          myDataSource.sendRequest("breed=Greyhound", oCallback);

          I just want all the results!

          Thanks again for any responses!
        • Satyam
          ... The oResponse of the code box is called oParsedResponse in the paragraphs just above. ... The first argument can be an empty string, which will be appended
          Message 4 of 4 , Sep 1, 2008
          • 0 Attachment
            Josh Lizarraga wrote:
            > Thank you for your response, but now I have the same problem with
            > sendRequest - I don't know what oResponse is supposed to be in my
            > case. I understand what oCallback is/does.
            >
            The oResponse of the code box is called oParsedResponse in the
            paragraphs just above.
            > In the example, oResponse is used to narrow down the results to only
            > greyhounds:
            >
            > myDataSource.sendRequest("breed=Greyhound", oCallback);
            >
            >
            The first argument can be an empty string, which will be appended to the
            base URL, leaving it unchanged.
            > I just want all the results!
            >
            > Thanks again for any responses!
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - http://www.avg.com
            > Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date: 29/08/2008 18:12
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.