<?xml version="1.0" encoding="UTF-8"?>
<data columns="12" rows="0"/>
how can get attributes (rows) of root (data) element in jquery?
i can with
var records = $(xml).find(":first").parent().attr("rows");
but not works :-/
thanks Rob
The root element of an XML message is based on an object structure and an operation specified for the channel or service used for the communication. The root element can contain one or more attributes. The following table shows the attributes that can apply to root elements.
While a properly formed XML file can only have a single root element, an XSD or DTD file can contain multiple roots. If one of the roots matches that in the XML source file, that root element is used, otherwise you need to select one to use. Choose the root to display. Select the root element you want to use.
The <html> HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element.
Each XML document has exactly one single root element. It encloses all the other elements and is, therefore, the sole parent element to all the other elements. ROOT elements are also called document elements. In HTML, the root element is the <html> element.
If it is a root node, use .filter()
instead of .find()
.
var records = $(xml).filter(":first").attr("rows");
jQuery's .find()
selects by searching inside the root nodes, while .filter()
selects from among the root nodes.
Try
var records = $(xml).find("data").attr("rows");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With