< Script Type = " Text/JavaScript " SRC = " Sg_mirror.js " > < / SCRIPT>
< Script Type = " Text/JavaScript " >
VaR XML = SG. xmldocument ();
XML. Load ( " Xmlfeedbacktemplate. xml " );
VaR Columnsnode = XML. selectsinglenode ( " Schema/Summary/columns " );
VaR Rowsnode = XML. selectsinglenode ( " Schema/rows " );
VaR Row = XML. createelement ( " Row " );
For ( VaR I = 0 , J = Columnsnode. childnodes. length; I < J; I ++ )
{
// Both of the following are acceptable:
// Alert (columnsnode. childnodes [I]. attributes [0]. value );
// Alert (columnsnode. childnodes [I]. getattribute ("columnname "));
Row. setattribute (columnsnode. childnodes [I]. getattribute ( " Columnname " ), I );
}
Rowsnode. appendchild (ROW );
// Locate the row's parent node and access it through childnodes
For ( VaR I = 0 , J = Rowsnode. childnodes [ 0 ]. Attributes. length; I < J; I ++ )
{
Alert (rowsnode. childnodes [0]. Attributes [I]. value );
}
// Or you can directly locate the child node of rows.
VaR Rownode = XML. selectsinglenode ( " Schema/rows/row " );
For ( VaR I = 0 , J = Rownode. Attributes. length; I < J; I ++ )
{
Alert (rownode. attributes [I]. value );
}
< / SCRIPT>
XML reference previousArticle!
Note: When adding a new row element, createelement
Node search:
// Search for nodes with a certain attribute
VaR findnode = xml. selectsinglenode ("schema/rows/row [@ indexid = '12']");
Alert (findnode. getattribute ("indicator classification "))
If you are looking for elements that meet the requirements, remove @. For more information, see the relevant XPath documents.