c# - Reading XML with a colon (:) -
i'm trying views of video following xml document (https://gdata.youtube.com/feeds/api/videos?q=example), i'm able link , autor because there no colon in tag.
i'm trying yt:statistics i've no idea how.
result = e.result.replace("xmlns='http://www.w3.org/2005/atom' ", string.empty); xmldocument doc = new xmldocument(); doc.loadxml(result); xmlnodelist videos = doc.getelementsbytagname("entry"); foreach (xmlnode video in videos) { xmlnode insideauthor = video.selectsinglenode("author"); string videoid = video.selectsinglenode("id").innertext.replace("http://gdata.youtube.com/feeds/api/videos/", string.empty); string author = insideauthor.selectsinglenode("name").innertext; // trying views of video of search results messagebox.show(video.selectsinglenode("yt:statistics").attributes["viewcount"].innertext); }
joery.
xmlnodelist videos = doc.getelementsbytagname("entry"); foreach (xmlnode video in videos) { string videoid = video["id"].innertext.replace("http://gdata.youtube.com/feeds/api/videos/", string.empty); string author = video["author"]["name"].innertext; string views = video["yt:statistics"].attributes["viewcount"].value; console.writeline(videoid); console.writeline(author); console.writeline(views); }
Comments
Post a Comment