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

Re: Query on http_parse_xml_string



   Yes, every thing else is working fine. I get the error only when the
   parser tries to parse the tag which has "&".

   For other tags, my parser procedure gets a call and I am able to get
   the data.

   If I remove the "&", everything works good.

   On Thu, Jan 12, 2012 at 10:45 AM, Alan Campin
   <[1]Alan.Campin@xxxxxxxxxxxxx> wrote:

     What does the &amp in your data mean? If you remove the &amp from
     the insert does everything work?

   -----Original Message-----
   From: [2]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [mailto:[3]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Abhijit
   Fulambrikar
   Sent: Thursday, January 12, 2012 9:34 AM
   To: HTTPAPI and FTPAPI Projects
   Subject: Re: Query on http_parse_xml_string
   Thanks Alan.
   This is how I am creating the test data in the SQLRPG program.
   exec sql
    values '<PopulateComments> +
            <ServiceRequest>406725</ServiceRequest> +
              <Comment> +
                 <Line>1</Line> +
                 <CreateDate>20111227</CreateDate> +
                 <CreateTime>145232</CreateTime> +
                 <Type>CAUSE</Type> +
                 <Text>Engine oil leak &amp; test</Text> +
               </Comment> +
               <Comment> +
                 <Line>2</Line> +
                 <CreateDate>20111227</CreateDate> +
                 <CreateTime>145232</CreateTime> +
                 <Type>CORRECTION</Type> +
                 <Text>Replace engine oil and other parts</Text> +
                </Comment> +
            </PopulateComments>' into :DataIn;

     *Input data*

   XMLDATA.@XMLDATA_DATA =
            ....5...10...15...20...25...30...35...40...45...50...55...60
       1   '<POPULATECOMMENTS> <SERVICEREQUEST>406725</SERVICEREQUEST> <'
      61   'COMMENT> <LINE>1</LINE> <CREATEDATE>20111227</CREATEDATE> <C'
     121   'REATETIME>145232</CREATETIME> <TYPE>CAUSE</TYPE> <TEXT>ENGIN'
     181   'E OIL LEAK &AMP; TEST</TEXT> </COMMENT> <COMMENT> <LINE>2</L'
     241   'INE> <CREATEDATE>20111227</CREATEDATE> <CREATETIME>145232</C'
     301   'REATETIME> <TYPE>CORRECTION</TYPE> <TEXT>REPLACE ENGINE OIL '
     361   'AND OTHER PARTS</TEXT> </COMMENT> </POPULATECOMMENTS>       '
     421   '                                                            '

     *Error*

    DATAOUT.@XMLDATA_DATA =
             ....5...10...15...20...25...30...35...40...45...50...55...60
        1   '<?xml version="1.0"?><POPULATECOMMENTS><Error>XML parse fail'
       61   'ed at line 1, col 191: undefined entity</Error></POPULATECOM'
      121   'MENTS>                                                      '
      181   '                                                            '
      241   '                                                            '
   When I change the Input Data and put  & instead of "&amp;" , below
   error is returned
   DATAOUT.@XMLDATA_DATA =
            ....5...10...15...20...25...30...35...40...45...50...55...60
       1   '<?xml version="1.0"?><POPULATECOMMENTS><Error>XML parse fail'
      61   'ed at line 1, col 192: not well-formed (invalid token)</Erro'
     121   'r></POPULATECOMMENTS>                                       '
   Is the function "http_parse_xml_string" capable of handling the special
   characters.
   Thanks for your help.
   Thanks & Regards,
   Abhijit
   On Wed, Jan 11, 2012 at 6:11 PM, Alan Campin <[4]alan0307d@xxxxxxxxx>
   wrote:
   >   The &amp is the same as putting an & in the xml because & are
   special
   >   characters I believe. The problem is that I don't think the EXPAT
   >   parser that Scott uses recognizes the & special strings like &quot,
   >   etc.
   >   When I dealt with problem it put the xml to a stream file and used
   >   XML-SAX to parse it and that recognized the special characters. I
   think
   >   this may be occurring because you have an xml file embedded inside
   the
   >   main file so you have to extract the files from inside and then
   parse
   >   it separately. This is not a problem if the resulting file is
   >   relatively small. It gets trickee if the file embedded inside is
   very
   >   big and won't fit in a variable. Then you need to write to a stream
   >   file.
   >   Would need to see the entire XML.
   >
   >   On Wed, Jan 11, 2012 at 4:24 PM, Abhijit Fulambrikar
   >   <[1][5]abhijit.fulambrikar@xxxxxxxxx> wrote:
   >
   >       Hi,
   >       I have a question regarding the parsing of special character's
   in
   >     XML.
   >       I am using "http_parse_xml_string" to parse the XML string.
   Please
   >     see
   >       the
   >       code below
   >       xmlError = http_parse_xml_string(%addr(xmlData.@xmlData_Data):
   >         xmlData.@xmlData_Len: 0: *null: xmlHandler: *null) <> 0;
   >       if xmlError;
   >         xmlAddRootAndElement(Process: ERROR: http_error());
   >       endif;
   >       The XML data which I am sending has the below tag which has
   >     special
   >       character "&". The character is formatted as "&amp;" as shown
   >     below
   >       <Text>Replace engine oil &amp; other parts</Text>
   >       The error which is returned from http_parse_xml_string is as
   below
   >       XML parse failed at line 1, col 349: undefined entity
   >       When I tried with the below data
   >       <Text>Replace engine oil & other parts</Text>
   >       I get the error as
   >       XML parse failed at line 1, col 350: not well-formed (invalid
   >     token)
   >       Please let me know if I am following some incorrect process.
   >     Thanks for
   >       your help.
   >       Regards,
   >       Abhijit
   >
   --------------------------------------------------------------------
   >     ---
   >     This is the FTPAPI mailing list.  To unsubscribe, please go to:
   >     [2][6]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   --------------------------------------------------------------------
   >     ---
   >
   > References
   >
   >   1. mailto:[7]abhijit.fulambrikar@xxxxxxxxx
   >   2. [8]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   >
   ----------------------------------------------------------------------

     > - This is the FTPAPI mailing list.  To unsubscribe, please go to:
     > [9]http://www.scottklement.com/mailman/listinfo/ftpapi
     >
     --------------------------------------------------------------------
     --
     > -
     >
     >
     -----
     No virus found in this message.
     Checked by AVG - [10]www.avg.com
     Version: 2012.0.1901 / Virus Database: 2109/4738 - Release Date:
     01/12/12

   -----------------------------------------------------------------------
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [11]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

References

   1. mailto:Alan.Campin@xxxxxxxxxxxxx
   2. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   3. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   4. mailto:alan0307d@xxxxxxxxx
   5. mailto:abhijit.fulambrikar@xxxxxxxxx
   6. http://www.scottklement.com/mailman/listinfo/ftpapi
   7. mailto:abhijit.fulambrikar@xxxxxxxxx
   8. http://www.scottklement.com/mailman/listinfo/ftpapi
   9. http://www.scottklement.com/mailman/listinfo/ftpapi
  10. http://www.avg.com/
  11. 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
-----------------------------------------------------------------------