stargateatlantis
asked on
jQuery Filter XML data
I have the following code below. I can load the XML no problems but what i want to do is filter the xml data so it will select the node with the id=1 and put title,teaser in separate variables.
<!-Start xml Code -->
<?xml version="1.0" encoding="iso-8859-1"?>
<stories>
<story id='1'>
<title>MyTitle 1</title>
<teaser>test</teaser>
<readmore>test</readmore>
</story>
<story id='2'>
<title>MyTitle 2</title>
<teaser>test</teaser>
<readmore>test</readmore>
</story>
<story id='3'>
<title>MyTitle 3</title>
<teaser>test</teaser>
<readmore>test</readmore>
</story>
</stories>
<!--End XML code --->
<!-- Start jQuery Code -->
<script type="application/javascript">
<!-- Avoid W3C validator on heavy javascript
$(document).ready(function() {
$.ajax({
type: "GET",
url: "xml/myxml.xml",
dataType: "xml",
success: function(xml) {
var returnRecord = $(xml).filter("[ id = 1 ]");
var str=jQuery.param(returnRecord);
}
}); //close $.ajax(
}); //
//-->
</script>
<!-- End jQuery Code -->
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.