Fabian,

Here's the js:

$(document).ready(function() {
        $.ajax({
                type: "GET",
                url: "sample.xml",
                dataType: "xml",
                success: function(data) {
                        $(data).find('item').each(function() {
                                var $item = $(this);
                                var $link = $item.find('link').text();
                                var $title = $item.find('title').text();
                                var $content = 
alert($item.find('content').text());
                        });
                }
        });
});

and here's a slimmed-down version of my XML file (this would be
contained in "sample.xml"):

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:content="http://
purl.org/rss/1.0/modules/content/" version="2.0">
<channel>
<title>Lorem Ipsum</title>
<link>http://www.sample.com</link>
<description>Lorem Ipsum lorem lorem</description>
<item>
<title>Lorem Ipsum</title>
<link>http://www.sample.com/2009/09/per-ma-link.html</link>
<description>Lorem Ipsum Lorem Ipsum lorem lorem Lorem Ipsum lorem
lorem Lorem Ipsum lorem lorem</description>
<content>&lt;p&gt;&lt;a href=&quot;http://www.sample.com/2009/09/per-
ma-link.html&quot; style=&quot;float: right;&quot;&gt;&lt;img
alt=&quot;Lorem Ipsum&quot; src=&quot;http://img.src&quot;</content>
<dc:creator>Author</dc:creator>
<pubDate>Tue, 08 Sep 2009 19:33:00 -0400</pubDate>
</item>
</channel>
</rss>

On Sep 24, 8:38 am, Fabdrol <fabd...@gmail.com> wrote:
> Hi Jeff,
>
> Could you post your JS code and your XML? I'd like to play around with
> it for you, but things aren't really clear right now ;-)
>
> Fabian
>
> On 23 sep, 21:36, Jeff <jpellet...@nesn.com> wrote:
>
> > Hi,
>
> > I'm using $.ajax with a dataType of xml.  The XML document I'm getting
> > has a <content> node that contains a bunch of encoded HTML.  Sample:
>
> > <content>&lt;p&gt;&lt;a href=&quot;
>
> > When I alert the text contained within the <content> node:
>
> > alert(data.find('content').text());
>
> > I can see the above encoded content as formatted HTML:
>
> > <p><a href="
>
> > I realize that the text() function is returning text, and not the
> > nodes within.  How can I return the nodes within, either as a jQuery
> > object or the DOM nodes themselves, rather than the text, so I can
> > actually parse them?
>
> > When I remove the .text() function from the above, ala:
>
> > data.find('content p');
>
> > I get Undefined.  I've tried all kinds of selectors, and nothing
> > works.
>
> > Finally data.find('content); returns object Object.
>
> > Thanks,
> > Jeff

Reply via email to