android - Parsing xml tags with colons inside using C# -
i'm working in xamarin on 1 android app parsing xml webiste: http://video.cazin.net/rss.php, , populate listview , in particular have problem getting value tag:
<media:thumbnail url="http://video.cazin.net/uploads/thumbs/2d07f1e49-1.jpg" width="480" height="360"/>
i created namespace:
xmlnamespacemanager.addnamespace("ab", "http://search.yahoo.com/mrss/");
and tried value url attribute:
xmlnodelist xmlnode = document.selectnodes("rss/channel/item"); if (xmlnode[i].selectsinglenode("//ab:thumbnail[@url='http://video.cazin.net/rss.php']", xmlnamespacemanager) != null) { var thumbnail = xmlnode[i].selectsinglenode("//ab:thumbnail=[@url='http://video.cazin.net/rss.php']", xmlnamespacemanager); feeditem.thumbnail = thumbnail.value; }
i tried this:
//ab:thumbnail/@url
but got value of first image. i'm sure problem here somewhere because have same code parisng images xml tag without colon inside , it's working correctly. had similar experience , knows should put in braces? thanks
your current query searching thumbnail
element url
attribute equal http://video.cazin.net/rss.php
- there none match this.
your 'i tried' query of //ab:thumbnail/@url
closer, //
means query start root of document, urls (but take first).
if want element matches taking current node context consideration, need include current node context in query - represented .
. .//ab:thumbnail/@url
find url
attributes in thumbnail
element contained current node. can see result in this fiddle.
i suggest use linq xml instead, however. it's lot nicer work old xmldocument
api. example, find item thumbnail urls using code:
var doc = xdocument.load("http://video.cazin.net/rss.php"); xnamespace media = "http://search.yahoo.com/mrss/"; var thumbnailurls = doc.descendants("item") .descendants(media + "thumbnail") .attributes("url");
Comments
Post a Comment