dataschema-table.mustache revision 11d2780adc5c17fefe1ea2d70c7e75ca6647c49c
4552N/A <p>DataSchema.XML can be used to retrieve data held in HTML TABLE elements.</p>
0N/A<p>DataSource.XML's `apply()` method supports passing in DOM nodes or document fragments. Use XPath strings to define data locations. In this example, we are retrieving data held in the rows of a TABLE element.</p>
0N/A data_out = Y.DataSchema.XML.apply(schema, tableEl);
1879N/A<p>If the table has a THEAD element and/or multiple TBODY elements, special considerations must be taken to apply the schema to the appropriate collection of TR elements. In the following complex example we leverage the power of the Node API to</p>
0N/A <li>and access only the TR elements contained in TBODY elements for data values, ignoring those TR elements in the THEAD.</li>
2127N/A thList = tableNode.all("th");
2122N/A thList.each(function(thNode, i){
3863N/A schema.resultFields = fields;
3863N/A tbody = document.createElement("tbody"),
3863N/A tbodyContainer = document.createDocumentFragment().appendChild(tbody);
0N/A var data_out = Y.DataSchema.XML.apply(schema, tbodyContainer);