XML Parsing in RPGLE ( IBMi/AS400)

 XML Parsing in RPGLE

In this section, we will learn about the process of parsing XML data using RPGLE language.


Directory Creation:

Step 1:  Write command-  crtdir on the command line and take F4.
                

Step 2:  Write a name for your directory and press enter- Here I am taking the name as "Tech Sharmit".

Step3: On pressing enter, we will get the message that the directory is created.



Step4: Now write command- wrklnk  on the command line and press enter.

















Step5: Here we got our newly created directory named as TechSharmit.

















XML File Creation:

Step6: Now take option 2 on your directory to create the xml file.
















Step7: Now write the name of xml file which you want to create for parsing, 
here I am creating the file as Data.xml (Use .xml as an extension after your file name).











Step8: Now take option I8 to insert 8 blank lines and press enter.














Step9: Now place your xml code here and press F3 to save and exit file.
( Please find the code  below- Code:01)

















Step10: Now create rpgle program and write code for parsing xml data.
( Please find the code below Code:02).

















Step11: Now compile the code to check the output.


Step12: Now call the program as shown below.



















Step13: This is the output of the program.



















Code01: XML file code

<Channel>                                    
    <Name> Tech Sharmit  </Name>             
    <Email> techsharmitgmail.com </Email>    
</Channel>                                   


Code02: RPGLE code for parsing (Coding: Fully Free Format)

 **Free                                                          
        DCL-S  FileName Varchar(500) INZ;                        
        DCL-S  Options varchar(500) INZ;                         
        DCL-S  Name varchar(50) INZ;                             
        Dcl-S  Email varchar(50) INZ;                            
        FileName = '/home/SHARMIT/TechSharmit/Data.xml';         
                                                                 
                                                                 
        options = 'case=any doc=file  path=Channel/Email';       
        xml-into Email %xml(%trim(FileName):options);            
                                                                 
        DSPLY Email;                                             
       *INLR = *on;                 

I have prepared a dedicated video for the same topic on my youtube channel
Please refer to the below link   
                                                        
                                                          

Thanks For Reading                             






Comments

Popular posts from this blog

Dynamic XMl file creation in IFS using RPGLE Program - IBMI / AS400

Compile Time Data Array in RPGLE - IBM i / AS400

Numeric Data type in RPGLE free format - IBM i / AS400