Reading XML, problem accesing and counting elements
I'm trying to access an XML file, but it doesn't seem to work, this is an example of the XML:
-
<?xml version="1.0" encoding="ISO-8859-1"?>
<pics>
<pic>
<autor>rtteewt</autor>
<desc>trhtrhtreherhetrhhrh</desc>
</pic>
<pic>
<autor>tewtewt</autor>
<desc>hytjyujryukukyyu.</desc>
</pic>
<pic>
<autor>5yutru</autor>
<desc>fghgyhvehtyudyd</desc>
</pic>
<pic>
<autor>jhgjgfj</autor>
<desc>trhythtrjtikui</desc>
</pic>
</pics>
This is a simple jquery function I'm using just to check if Im able to read the content:
-
var total = 0;
function readXML(section)
var xml = $.ajax(
{
type: "GET",
url : "xmldocs/picslist.xml",
dataType: "xml",
success: function(xml)
{
total = xml.getElementsByTagName("pic").length;
}
});
alert(total);
}
I'm getting 0 all the time...