Loading XML with JQuery -
i'm working on dog web site xml back-end.
<?xml version="1.0" encoding="utf-8"?> <breeder> <dog> <dogs_id>001</dogs_id> <dogs_image>../images/eclipse.jpg</dogs_image> <dogs_breeding_name>eclipse</dogs_breeding_name> <dogs_given_name>coco</dogs_given_name> <sex>female</sex> <dogs_mom>juno</dogs_mom> <dogs_dad>brutus</dogs_dad> <dogs_pedigree>../pedigrees/pedigree - kodiak.jpg</dogs_pedigree> <dogs_pedigree_status>active</dogs_pedigree_status> <alaa_registration>alaa - 000000</alaa_registration> <microchip_no>0000</microchip_no> <eye_colour>copper</eye_colour> <colour_genetics>bbee, kyky, ata, ssp</colour_genetics> <coat_colour>chocolate , tan phantom</coat_colour> <adult_height>16"</adult_height> <coat_type></coat_type> <adult_weight>20lbs</adult_weight> <size>mini</size> <profile>words kodiak</profile> <breeders_notes></breeders_notes> </dog> <dog> <dogs_id>002</dogs_id> <dogs_image>../images/danny.jpg</dogs_image> <dogs_breeding_name>danny boy</dogs_breeding_name> <dogs_given_name>danny</dogs_given_name> <sex>male</sex> <dogs_mom>doodle's rosie</dogs_mom> <dogs_dad>dehler's jack </dogs_dad> <dogs_pedigree>../pedigrees/pedigree - danny.jpg</dogs_pedigree> <dogs_pedigree_status>active</dogs_pedigree_status> <alaa_registration>alaa- 000000</alaa_registration> <microchip_no></microchip_no> <colour_genetics>bbee, kyky, atat</colour_genetics> <eye_colour></eye_colour> <coat_colour>very dark red, invisible phantom</coat_colour> <adult_height>16"</adult_height> <coat_type></coat_type> <adult_weight></adult_weight> <size>mini</size> <profile>words danny</profile> <breeders_notes></breeders_notes> </dog>
i can xml load in table want able move each of fields around , filter data on field "sex" "male , female".
this code have used on html page load xml.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready( function() { $.ajax({ type: "get", url: "../xml/dogs.xml", datatype: "xml", $(".dogs-info").children().remove;// clear text field success: xmlparser }); function xmlparser(xml) { $(xml).find("dog").each(function () { var i= $(this); var profiletext= (i).find("profile").text() $(".dogs-info").append('<html>' + profiletext + '</html>'); }); } </script>
3 questions 1. why isn't xml loading page? 2. how filter data on field "sex" either male or female. 3. come actionscript world there substitute trace()?
hope can :-) reading if made far!
you can't have
$(".dogs-info").children().remove;
smack in middle of ajax request object; needs somewhere else first line ofxmlparser
.you don't have closing
});
$(document).ready( function() {
why putting
profiletext
inside<html>
tags?