cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

XML parsing to JSL Help

Hi Everyone,

 

I have been stuck on this XML parsing data to JSL for awhile, I can do it at one level but not at 2 levels.

 

I have this XML as below:

 

<Menu name="AAA" role="PP">

<Item name="XXX" value="-11.9" />

<Item name="YYY" value="7.1" />

<Item name="Tool" value="121"/>

<Item name="POSITION" value="301"/>

<Item name="ID" value="1562" />

</Menu>

<Menu name="BBB" role="PP">

<Item name="XXX" value="-1.9" />

<Item name="YYY" value="4.1" />

<Item name="Tool" value="121"/>

<Item name="POSITION" value="301"/>

<Item name="ID" value="1562" />

</Menu>

 

I need the output table to look like this one:

AAA_XXX

AAA_YYY

BBB_XXX

BBB_YYY

-11.9

7.1

-1.9

4.1

 

So far, I have this JSL code but it can only do IF condition at 1 level, but not at 2 levels for Menu and Item.

On Element( "Item",
			Starttag(
				If( XML Attr( "name") == "XXX", 
					column( dt, "AAA_XXX")[row()] = Num( XML Attr( "value"))/10;
				);
				If( XML Attr( "name") == "YYY",
					column( dt, "AAA_YYY")[row()] = Num( XML Attr( "value"))/10;
				);
                                If( XML Attr( "name") == "XXX", 
					column( dt, "BBB_XXX")[row()] = Num( XML Attr( "value"))/10;
				);
				If( XML Attr( "name") == "YYY",
					column( dt, "BBB_YYY")[row()] = Num( XML Attr( "value"))/10;
				);
)

Can you please kindly help me out?

 

Thank you.

2 REPLIES 2
jthi
Super User

Re: XML parsing to JSL Help

I would most likely start by trying the interactive XML import wizard

jthi_0-1691779558453.png

jthi_1-1691779575867.png

From here you can clean the data and modify it if needed and then you can split it

jthi_2-1691779618709.png

 

JMP is able to record most of the steps you need to get here (check enhanced log and source scripts of tables)

-Jarmo
Craige_Hales
Super User

Re: XML parsing to JSL Help

I like it!

Craige

Recommended Articles