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

Re: Expat XML complex document read.



   Hi Richard,
   you could also try to use the RPGLE based xmlReader in powerEXT Core,
   it works alone or with CGIDEV2 or with HTTPAPI ...
   // Read the XML file into memory again xmlFromStmf method
   xmlFromStmf(tmpFile);

   // Initialize the xmlReader
   xmlReaderInz(xmlAddr:xmlSize);

   // Set Case of Element And Attribute Names
   xmlReaderCase('L');
   // Read the XML
   dow xmlReader = 0;
     select;
       when xmlGetNode = 'ordernumber' and xmlGetAttr = '';
         dsp = 'Order No: ' + xmlGetData;
         dsply dsp;
     endsl;
   enddo;

   // Free XML storage
   xmlFree();
   For more information and download go to my homepage
   Regards
   Henrik
   [1]Homepage: powerEXT.com

   <richbelcher@xxxxxxx>
   Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

   19-05-2010 00:22

                             Please respond to
        HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                       To

   HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                       cc

                                                                  Subject

   Re: Expat XML complex document read.

   I thought  this would be the place to ask the question because of
   using the EXPAT library and example program that I used to access the
   XML.  Because of privacy information I will have to use a dummy
   example.
   <xml>
     <CustomerOrder>
         <TransactionDate>2010-05-14</TransactionDate>
         <TransactionEffectiveDate>2010-05-01</TransactionEffectiveDate>
         <ShippingAddress>
              <CompanyName>Some Company</CompanyName>
              <Addr1>123 any street</Addr1>
              <City>Town</City>
              <State>AZ</State>
              <Zip>85015</Zip>
          </ShippingAddress>
          <ShipTo>
               <Consignee>My Company</Consignee>
               <Addr1>456 another street</Addr1>
               <City>My Town</City>
               <State>CA</State>
               <Zip>99001</ZIp>
           </ShipTo>
           <OrderInfo>
                <OrderNumber>012345</OrderNumber>     (Primary Key of
   tables)
                <ShipDate>2010-05-30</ShipDate>
            </OrderInfo>
            <OrderItems>
                 <Part>1234</Part>
                 <Desc>One product</Desc>
                 <Quantity>1</Quantity>
                 <Price>10.00</Price>
                 <Part/>2345</Part>
                 <Desc>Another product</Desc>
                 <Quantity>5</Quantity>
                 <Price>20.00</Price>
             </OrderItems>
             <SpecialInstructions>
                  <ShipDirections>Ship during business
   hours</ShipDirections>
             </SpecialInstructions>
     </CustomerOrder>
   </xml>
   The XML document I am working with has allot more detail but the above
   example is kind of what I am facing.  The primary key for the load to
   the tables is several elements down in the document and the prior
   information is also needed for one of the tables.  In using the
   CUSTDATA2 example the only way I can think of retaining the data is
   use data structures to load to in the subprocedure and then bring them
   back up into the mainline of the program to process the information.
   The only problem with scenario is I am referencing one order where
   ther could be multiple orders within the same XML document.
   Hope that clears it up some.  I have also used to HTTPAPI to access to
   separate web services and would like to thank you for the example I
   was able to use in the library.  I did sign up in the iSystems forums
   but have not figured out where to post the question yet.
   Thanks
   Richard.
   ---- Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
   > Hi Richard,
   >
   > I'm having a hard time visualizing the problem.  Would a simple
   example
   > be possible?
   >
   > Also, can we move this to the System iNetwork forums?  It doesn't
   appear
   > to be related to HTTPAPI or FTPAPI.
   > http://forums.systeminetwork.com
   >
   > Thanks!
   >
   >
   > On 5/18/2010 4:14 PM, richbelcher@xxxxxxx wrote:
   > > Hi Scott,
   > >
   > > I am attempting to use the CUSTDATA2 example in LIBEXPAT to read
   in
   > > an XML document with whitespace that is complex and the data is
   not
   > > in the order to attempt to write it out to keyed tables.  The
   primary
   > > key is buried several columns past the beginning of the data.  I
   am
   > > able to get the table copied to the IFS and the program is reading
   it
   > > but I am having a problem trying to think of a logical way to
   extract
   > > the data into elements.  I thought about data structures, but I am
   > > dealing with populating about 15 different tables with
   information.
   > > I also attempted to use the new XML-SAX and XML-INTO operations
   but
   > > the complexity and length of the column names make that option not
   a
   > > valid one.  Any suggestions on how to get the data out and into
   > > tables?  This is going to be an ongoing experience for me and I'm
   a
   > > little buffalo'ed on the correct way to handle this.
   > >
   > > Thanks
   > > Richard
   >
   >
   ----------------------------------------------------------------------
   -
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > 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
   ----------------------------------------------------------------------
   -

References

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