facebook

parsing cdata problem : CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #348961 Reply

    AdamRogan
    Member

    Ok im using the dynlist-demo example project to load a rss feed.
    Im trying to parse a xml file.
    Image , title, parses fine but nothing in the cdata section is being parsed.
    this is my xml code.
    <item>
    <title>My title</title>
    <pubDate>19/3/2014</pubDate>
    <description>
    <![CDATA[
    <p style=”margin-left:10px;margin-right:10px;”><b>text content goes here.</b><br<br>
    ]]>
    </description>
    <image>
    http://website/image/image.png
    </item>

    and this is the script.

    var selItem = $(event.srcElement).closest(‘li[data-listitem-index]’);
    var itemId = $(selItem).attr(“data-listitem-index”);
    var list_items = $(“:root”).data(“topsongs”);
    var item = list_items[itemId];

    var title = item[“title”];
    var desc = item[“description”];
    var image = item[“image”];
    var cont = item[“content”];

    $(“#m1-view_song-txt”).text(title);
    $(“#m1-view_song-txt”).text(desc);
    $(“#m1-view_song-img”).attr(“src” , image);

    function load_top25(active_page){

    var list_items = new Array();

    phoneui.showActivityDialog(“Loading the feed…”);

    $.get(“http://mysite.com/trending.xml&#8221;, function(data) {
    var $xml = $(data);
    $xml.find(“item”).each(function() {
    var $this = $(this),
    item = {
    title: $this.find(“title”).text(),
    desc: $this.find(“description”).attr(“term”),
    image: $this.find(“image”).text()
    }
    list_items.push(item);
    });

    $(“:root”).data(“topsongs” , list_items);

    render_list(active_page, list_items);
    phoneui.hideActivityDialog();

    });

    }

    Im not sure how to parse the cdata in description.

    any help would be great.
    cheers………….

    #348972 Reply

    support-michael
    Keymaster
    #348990 Reply

    AdamRogan
    Member

    Thanks for that, got it working….
    Now i have a another problem with the text being parsed is not wrapping.
    any ideas on fixing that?
    cheers

    #349008 Reply

    AdamRogan
    Member

    All fixed and done, cheers thanx.
    you can close this thread…………………………………………………

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: parsing cdata problem : CLOSED

You must be logged in to post in the forum log in