<?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
<?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
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.
This might not be working because it is having trouble finding the first element using the query you specified. This might be of some use to you:
http://stackoverflow.com/questions/1650063/selecting-root-element-in-jquery
After that .attr("rows") should work.