ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

read XML from the iseries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • read XML from the iseries

    This is an example from iseries 400 Experts Journal..
    which if your not a subscriber I would recommend
    best iseries publication out there... IMHO

    I just started messing with it....

    From Susan Gantner


    Kinda cool so far didnt think it was this easy...
    now this is a simple example using just a datastructure.

    I will try to use a procedure next.... requires the %Handler BIF

    anyway......This is working(V5R4) I'm trying to change the
    XML so that there are multiple shipto's:

    so

    PHP Code:
    <shiptos>
     <
    shipto></shipto>
     <
    shipto></shipto>
     <
    shipto></shipto>
    </
    shiptos
    Just not sure how to do this. I have added another qualified
    datastructure with dimensions...but I just cant make it work.
    It compiles but fails on the load.

    Anyway if anyone has any ideas please post away!

    The XML document and named xml.xml
    this is placed in folder /jamie which is located under
    the /root

    Any help is appreciated... (this version btw works fine)
    as long as there arent 101 customers coming down

    PHP Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <Customers>
        <Customer ID = "12345">
        <Contact>Bill Buckram</Contact>
        <Company>Pirate Steel Corporation</Company>
          <Address>
            <Street>1234 Jones St.</Street>
            <City>Anytown</City>
            <State>IL</State>
            <zip>61254</zip> 
        </Address>
          <shipto ID = "1">
         <Street>12 West pizza drive</Street>
         <City>BoysTown</City>
         <State>IL</State>
         <zip>61258</zip>
          </shipto> 
           </Customer>
     <Customer ID = "67890">
        <Contact>Joe Smoker</Contact>
        <Company>Tobacco Sales and Service</Company>
          <Address>
            <Street>5454 Smith Street.</Street>
            <City>Mytown</City>
            <State>IL</State>
            <zip>61548</zip> 
        </Address>
          <shipto ID = "1">
             <Street>333 mark avenue</Street>
             <City>DevilsVille</City>
             <State>WI</State>
             <zip>58458</zip>
                </shipto> 
           </Customer>
    </Customers>
    The code
    Code:
          //
          // Variable Definition
          //
         d cmdstring       s            512
         d cmdlength       s             15  5
         d ISodate         s               d
    
         d  customer       ds                  Qualified  dim(100)
         d   ID                           5  0
         d   contact                     30A
         d   Company                     30A
         d   Address                           likeds(Address)
         d   Shipto                            likeds(Shipto)
    
         d  Address        ds                  Qualified
         d   street                      40
         d   city                        30A
         d   state                        2A
         d   zip                         10a
    
         d   shipto        ds                  Qualified
         d   ID                           5  0
         d   street                      40
         d   city                        30A
         d   state                        2A
         d   zip                         10a
    
    
         d $command        pr                  extpgm('QCMDEXC')
         d   command                   5000    options(*varsize)
         d   Length                      15  5
    
    
          /Free
    
    
            //--------------------------------------------------------
            // MAIN PROGRAM
            //--------------------------------------------------------
    
    
                   XML-Into Customer %XML('/jamie/xml.xml' :
                                          'case=any ' +
                                          ' doc=file path=Customers/Customer' +
                                          ' allowmissing=yes');
    
    
                 *inlr = *on;
    
          /End-Free
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: read XML from the iseries

    That's cool! Is this available on V5R3 via a PTF?
    Jonas Temple
    Got FROG?
    Got Tadpole? No, because it's not done yet! Stay tuned....

    01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

    Comment


    • #3
      Re: read XML from the iseries

      Im not sure... I wish I knew more...just had a couple of minutes to play today

      The procedure idea is cool cause you can process 1 element(record) at a time.

      I will post more as I experiment...
      I hope you all will do the same.

      jamie
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: read XML from the iseries

        well i have to admit that i really like what you are doing there jamie....but i don't quite understand it all....

        Here is what I do understand,
        I understand your use of the data structures....haha

        Now, are they preloaded before this code executes? Where are you pulling this info from? And finally, what are you using to write the <tags></tags> with?

        I'm new to the XML bit and i'm trying to understand how to generate it. I understand the accessing it like a tree and all, but as far as generating the file i'm still not quite up to speed. I don't know why, I just haven't found any great examples I guess.
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: read XML from the iseries

          Bryce,

          The XML is created in outer space and some how thru Wicken magic
          it gets placed on the IFS.........

          The program only reads the XML file once its on the IFS.
          its a very simple example and its only available on V5R4 as far as
          I know... (maybe PTF 's to run on V5R3)

          once the document is read it must be validate then written to
          an iseries table.

          jamie
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: read XML from the iseries

            If like some of us, you are stuck at V5R3, Scott Klement has a utility in his HTTPAPI utility (http://www.scottklement.com/httpapi/) that can be used to parse XML. It also uses a data structure and allows processing one "row" at a time. The utility is free and comes with bunches of example programs.

            Comment


            • #7
              Re: read XML from the iseries

              Thanks mark......

              The more examples the better
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: read XML from the iseries

                Sorry Jamie,

                I didn't realize there was so much magic in the beginning of the example. I get it now.

                Your future President
                Bryce

                ---------------------------------------------
                http://www.bravobryce.com

                Comment


                • #9
                  Re: read XML from the iseries

                  no trouble......I have ways to get the ifs file to the ifs......but thats not important here...

                  the example will work as is and is kinda cool....well as cool as friggen RPG can get



                  jamie
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: read XML from the iseries

                    Just now getting interested in XML on the iSeries as I'm playing around with some USPS web services. I can create the outbound XML using CGIDEV2. I guess I'm trying to understand the XML coming back! Can I capture the response from the browser and deal with it as I do other web query strings? Or do I have to save the response off as a .XML document in the IFS to deal with it and use XML-INTO ?
                    Your friends list is empty!

                    Comment

                    Working...
                    X