Subscribe Bookmark RSS Feed

Reading XML file

jeffjy

Staff

Joined:

Aug 29, 2011

Hi guys,

Any one try to use JMP to work with XML file before? Can JMP import XML file?

2 REPLIES
jschroedl

Staff

Joined:

Jun 23, 2011

JMP has functions for loading and parsing XML.

If you have the XML as text strings, use ParseXML

 

ex =
"<table name='fromxml'><col name='x'>[1 2 3]</col><col name='y'>[11 22 33]</col></table>";
Parse XML( ex,
     On Element(
          "table",
          Start Tag(
               New Table( XML Attr( "name" ) )
          )
     ),
     On Element(
          "col",
          End Tag(
               New Column( XML Attr( "name" ),
                    Set Values( Parse( XML Text() ) )
               )
          )
     )
);

From a file:

Parse XML( LoadTextFile("c:\temp\test.xml"),
          "table",
     On Element(
          Start Tag(
               New Table( XML Attr( "name" ) )
          )
     ),
     On Element(
          "col",
          End Tag(
               New Column( XML Attr( "name" ),
                    Set Values( Parse( XML Text() ) )
               )
          )
     )
);
ix_stats

Community Member

Joined:

Apr 30, 2013

Hi Jschroedl,

I have an XML file with contents as shown below. I was trying to create a JMP table from it.

How do i write the jsl so that I can pick up the value in the 'Type' field in folder "CD" which would be '0' and not pick up the '1' from the "DD" folder (also with a 'Type' field but is within "CD")?

Thanks.

XML contents:

- <Summary_Log>

  - <Info>

    <UID>AA11</UID>

    <Ver>1.0</Ver>

    - <CD>

      <UID>AA11</UID>

      <Type>0</Type>

      - <DD>

        <UID>AA11</UID>

        <Type>1</Type>

        </DD>    

      </CD>

    </Info>

</Summary_Log>