该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


Parse XML( string, On Element( "tagname", Start Tag( expr ), End Tag( expr ) ) );
parses an XML expression using the On Element() expression for specified XML tags.
value = XML Attr( "attribute name" );
Suppose that a Microsoft Excel file contains one row of data from Big Class.jmp. The file is saved as the valid XML document BigclassExcel.xml, shown here and also saved in the JMP Samples/Import Data folder.
The following script reads BigclassExcel.xml and creates a JMP data table with the information in it. This script, named ParseXML.jsl, is in the JMP Samples/Scripts folder.
file contents = Load Text File( "$SAMPLE_IMPORT_DATA/BigclassExcel.xml" );
Parse XML( file contents,
"urn:schemas-microsoft-com:office:spreadsheet^Worksheet",
sheetname = XML Attr(
"urn:schemas-microsoft-com:office:spreadsheet^Name",
"Untitled"
dt = New Table( sheetname );
"urn:schemas-microsoft-com:office:spreadsheet^Row",
If( row > 1, // first row has column names
dt << Add Rows( 1 )
OnElement( "urn:schemas-microsoft-com:office:spreadsheet^Cell", EndTag( col++ ) ),
"urn:schemas-microsoft-com:office:spreadsheet^Data",
data = XML Text( collapse );
New Column( data, Character( 10 ) ),
// first row has column names
Column( col )[row - 1] = data
); // and other rows have data