2

I have the following XML

<?xml version="1.0" encoding="UTF-8"?>
<channel>
<item>
<title>Title One</title>
<g:image_link>Link One</g:image_link>
</item>
<item>
<title>Title Two</title>
<g:image_link>Link Two</g:image_link>
</item>
</channel>

The following jQuery I am using to parse this XML and then do as I need with the values

    $.ajax({
            type: "GET",
            url: "test.xml",
            dataType: "xml",
            success: parseXml,
            failure: function(data){
                alert("XML File could not be found");
            }
        });
function parseXml(xml){
            $(xml).find("item").each(function(){
                alert((this).find("title"));
            }); 
        }

This will output the title as expected. What I am struggling to do is simply alert the .text() of g:image_link simply putting this node name will not it seems give me what I desire.

Thanks

  • Semi-colon? I don't understand. – Dave Newton Jun 14 '12 at 14:06
  • 6
    Oh, you mean namespaces, like [this](http://stackoverflow.com/questions/853740/jquery-xml-parsing-with-namespaces), [this](http://stackoverflow.com/questions/5463417/parsing-xml-namespace-with-jquery-help-needed), etc.? – Dave Newton Jun 14 '12 at 14:15
  • Thats brilliant! thanks, I never spotted that! –  Jun 14 '12 at 14:17

1 Answers1

2

Answer can be found in the comment by Dave Newton

  • There's also this: http://www.rfk.id.au/blog/entry/xmlns-selectors-jquery/ - but I couldn't get that to work, sounds promising enough though ;-) – Ja͢ck Jun 14 '12 at 14:36