fefe
fefe

Reputation: 9065

xml parsing error with jquery

Why do I get Invalid XML when I parse with jquery xml

$(document).ready(function() {
    var xml = '<?php echo XML_CONFIGS . '/feed_config.xml' ?>';
    $("#sql_config").click(function(e) {
     e.preventDefault();  
     xmlDoc = $.parseXML(xml ),
     $xml = $( xmlDoc ),
     $feed = $xml.find( "feed[id = 4]" );

     console.log($feed);
        var data = $('#sql').serialize();              
    }); 

The hosted xml http://ui.kakuki.de/feed_config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <element>
        <feed id=" 4 ">
            <title>My Feed</title>
            <table>my_table</table>
            <link>http://testsite.com/export/export?myFeed=13&amp;myFormat=134251570</link>
            <feed_type>XML</feed_type>
        </feed>
        <query/>
    </element>
</config>

Upvotes: 0

Views: 878

Answers (1)

Sphvn
Sphvn

Reputation: 5353

The $.parseXML(xml) and XML all seems fine and loads for me in all browsers I have tested with.

However your $xml.find will return an empty array as your id is incorrect.

Your id isn't 4 its " 4 " so your find should be $xml.find("feed[id=\" 4 \"]")

Glad I could help.

Upvotes: 1

Related Questions