[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Parsing XML with a value that contains a double quote



   Hello again,


   I'm using a pointer to read the large amount of data being returned in
   the http_url_post_xml response. I know how to use a pointer to read
   data coming in from a file in the IFS, but what about data that simply
   resides in memory? I'm sure I'm just missing something very elementary
   here.


   Here are relevant snippets of my code:


   I've got a data structure that contains a pointer and a length:


        D value_t         ds                  qualified

        D   valptr                        *

        D   len                         10i 0


   I've altered my EndOfElement prototype definition to include the data
   structure:


        D EndOfElement    PR

        D   UserData                      *   value

        D   depth                       10I 0 value

        D   name                      1024A   varying const

        D   path                     24576A   varying const

        D   retval                            likeds(value_t)

        D   attrs                         *   dim(32767)

        D                                     const options(*varsize)



   I'm using http_XmlReturnPtr:


     http_XmlReturnPtr(*ON);



   My call to the web service looks like this:


         rc = http_url_post_xml(

             'https://someurl.com/services/eoservice.asmx'

                   : %addr(SOAP)+2

                   : %len(SOAP)

                   : %paddr(StartOfElement)

                   : %paddr(EndOfElement)

                   : *NULL );




   The return tag "DeliverExamOneContentResult" contains all the
   unescaped data that I want to write to a temporary file in the IFS, so
   I can read it back in and parse it with http_parse_xml_stmf.


        P EndOfElement    B

        D EndOfElement    PI

        D   UserData                      *   value

        D   depth                       10I 0 value

        D   name                      1024A   varying const

        D   path                     24576A   varying const

        D   retval                            likeds(value_t)

        D   attrs                         *   dim(32767)

        D                                     const options(*varsize)


        D writeToFile     PR            10I 0 ExtProc('write')

        D  fildes                       10i 0 value

        D  buf                       65535A   const options(*varsize)

        D  bytes                        10U 0 value


        D xmlhdr          s             80a   varying

        D fd              s             10i 0


         /free


              if (%trim(name) <> 'DeliverExamOneContentResult');

                return;

              endif;


              // ------------------------------------------

              //   create new stream file in IFS

              // ------------------------------------------


              embfile = http_tempfile();


              // ------------------------------------------

              //    Open stream file for appending data

              //    and write embedded XML document to it

              // ------------------------------------------


              fd = open(embfile: O_WRONLY+O_TEXTDATA);


              xmlhdr= '<?xml version="1.0"?>' + x'0d25';

              writeToFile(fd: xmlhdr: %len(xmlhdr));


        // here's where the problem is - how to I retrieve the data from
   memory?

        // Whenever I use %addr(retval.valptr), I get a compile error:

        // The type of the parameter specified for the call does not
   match the prototype.


              dow writeToFile(fd: %addr(retval.valptr) : retval.len)>=0;

                writeToFile(fd: %addr(retval.valptr) : retval.len);

              enddo;


              callp close(fd);



           //endsl;


         /end-free

        P                 E


   I see that retval.valptr is a pointer and parameter buf in writeToFile
   is a character field---how do I return the data at pointer
   retval.valptr? What am I missing?


   Thanks for your help--again!


   Kim Gibson


   From: Kim Gibson
   Sent: Tuesday, December 21, 2010 3:28 PM
   To: 'ftpapi@xxxxxxxxxxxxxxxxxxxxxx'
   Subject: RE: Parsing XML with a value that contains a double quote


   Great--thanks, Scott! I knew there had to have been some cool feature.


   I appreciate your help. Have a wonderful holiday!


   Kim Gibson



   On 12/21/2010 2:44 PM, Kim Gibson wrote:

   > Any quick ideas on solutions?? I'm doing some research on this end,

   > and chances are the solution will be absurdly simple.


   HTTPAPI has a feature called HTTP_xmlReturnPtr() that lets HTTPAPI

   return the 'value' parameter from an XML document as a pointer to

   allocated memory.  That allows the value of an XML element to exceed

   65535.  (Indeed, should be capable of 16mb)


   Here's a link to a previous discussion of HTTP_xmlReturnPtr:

   [1]http://www.scottklement.com/archives/ftpapi/201008/msg00110.html


   If you use that feature, you should be able to write all of the data

   from your "embedded XML" into an IFS stream file.  (Which, of course,

   doesn't have a size limit.) and then your 2nd parse should work
   properly.


   ----------------------------------------------------------------------
   -

   This is the FTPAPI mailing list.  To unsubscribe, please go to:

   [2]http://www.scottklement.com/mailman/listinfo/ftpapi

References

   1. http://www.scottklement.com/archives/ftpapi/201008/msg00110.html
   2. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------