Previous Next        Current Page: NeXtMidas Training / Working with Files / File Types / XML (.xml) Files
back
+ Start Here   
+ Background   
+ Common Midas Concepts   
+ Getting Started - Part 1   
+ Getting Started - Part 2   
- Working with Files   
   - File Basics   
   + The AUX List   
   + Basic File Commands   
   + Lab 1   
   + File Names   
   - File Types   
      - File Handlers   
      - Handlers Table   
      - File Interfaces   
      - Supported File Types   
      - Table (.tbl) Files   
      - XML (.xml) Files   
   + Lab 2   
   + Listing Files   
   + Lab 3   
   + Plotting Files   
   + Lab 4   
+ Option Trees   
+ Macros - Part 1 (Basics)   
+ Macros - Part 2 (Graphics)   
+ NetBeans - Part 1 (Setup)   
+ NetBeans - Part 2 (GUIs)   
+ NetBeans - Part 3 (Profiler)   
+ Eclipse - Part 1 (Setup)   
+ Eclipse - Part 2 (GUIs)   
+ Primitives   
+ WebStart   
+ Maps & Imagery   
+ X-Midas Interoperability   
+ RMIF & Remoting   
+ Installing NeXtMidas   
+ Support & Maintenance   
+ File Handlers   


  • XML (.xml) Files:
    • XML files can be converted to tables via the simple method:
      • nM> res T:tab myfile.xml
      or by using the CONVERT command with simple files or CGI scripts which return xml.
      • nM> convert myfile.xml XML2TAB tab
      • nM> convert http://myhost:myport/cgi-bin/myscript.pl XML2TAB tab
    • A sample xml (fleet.xml) file:
      <XML>
        <CAR DOORS="4" CYLINDERS="4"> 4 Door Car </CAR>
        <TRUCK DOORS="2" CYLINDERS="8"> 2 Door Truck </TRUCK>
        <FLEET> X="1" Y="2" Z="3"
          <CAR> NAME="CHEVETTE" HP="50" COLOR="BABYBLUE" </CAR>  
          <CAR> NAME="CORVETTE" HP="350" COLOR="RED" </CAR>  
        </FLEET>
      </XML>
    • can be loaded into a table using the short-cut method shown above. (Note that an underscore (_) is added to XML tags at the same level with the same name)
      nM> res t:tbl fleet.xml
      nM> res/all tbl
        T: TBL             = Table of 3 entries
        T: TAB             = Table of 3 entries
        T:  CAR            = Table of 3 entries
       1S:   DOORS         = 4
       1S:   CYLINDERS     = 4
      10S:   CDATA         = 4 Door Car
        T:  TRUCK          = Table of 3 entries
       1S:   DOORS         = 2
       1S:   CYLINDERS     = 8
      12S:   CDATA         = 2 Door Truck
        T:  FLEET          = Table of 3 entries
      17S:   CDATA         = X="1" Y="2" Z="3"
      40S:   CAR_1         = NAME="CHEVETTE" HP="50" COLOR="BABYBLUE"
      36S:   CAR_2         = NAME="CORVETTE" HP="350" COLOR="RED"
      
      or by using the CONVERT command:
      nM> convert/delim="__"/comp=ON fleet.xml XML2TAB tbl
      nM> res/all tbl
        T: TBL             = Table of 3 entries
        T:  CAR            = Table of 3 entries
       1S:   DOORS         = 4
       1S:   CYLINDERS     = 4
      10S:   CDATA         = 4 Door Car
        T:  TRUCK          = Table of 3 entries
       1S:   DOORS         = 2
       1S:   CYLINDERS     = 8
      12S:   CDATA         = 2 Door Truck
        T:  FLEET          = Table of 3 entries
      17S:   CDATA         = X="1" Y="2" Z="3"
      40S:   CAR__1        = NAME="CHEVETTE" HP="50" COLOR="BABYBLUE"
      36S:   CAR__2        = NAME="CORVETTE" HP="350" COLOR="RED"
      
    • Using the CONVERT command, one can control the delimiter used for duplicate tags as well as the character data compression for tags with no params (such as the CAR tags in this XML)
      With character data compression off the resultant XML looks like:
      nM> convert/delim="__"/comp=OFF fleet.xml XML2TAB tbl
      nM> res/all tbl
        T: TBL             = Table of 3 entries
        T:  CAR            = Table of 3 entries
       1S:   DOORS         = 4
       1S:   CYLINDERS     = 4
      10S:   CDATA         = 4 Door Car
        T:  TRUCK          = Table of 3 entries
       1S:   DOORS         = 2
       1S:   CYLINDERS     = 8
      12S:   CDATA         = 2 Door Truck
        T:  FLEET          = Table of 3 entries
      17S:   CDATA         = X="1" Y="2" Z="3"
        T:   CAR__1        = Table of 1 entries
      40S:    CDATA        = NAME="CHEVETTE" HP="50" COLOR="BABYBLUE"
        T:   CAR__2        = Table of 1 entries
      36S:    CDATA        = NAME="CORVETTE" HP="350" COLOR="RED"
      

back