Solving the problem of colon-reading in XML _c# tutorial

Source: Internet
Author: User
Reference article: http://chs.gotdotnet.com/quickstart/howto/doc/Xml/XmlNameSpace.aspx

I Source:
public void Bindxml (string xmlUrl)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument ();
Doc. Load (system.appdomain.currentdomain.basedirectory+ "Kkjj.xml");
Doc. Load (XMLURL);
Doc. SelectNodes ("/rss/channel");
System.Xml.XmlNode root = Doc. DocumentElement;
System.Xml.XmlNode xn = root. selectSingleNode ("/rss/channel");
Outstr + = "Album name:" + xn. selectSingleNode ("title"). innertext;//Album name
Outstr + = "<br> album URL:" + xn. selectSingleNode ("link"). innertext;//album URL
Outstr + + <br> photo Album:
Outstr + = "<br>System.Xml.XmlNodeList xnl = xn. SelectNodes ("item");
Outstr + + <br> photo albums: + XNL. Count.tostring () + "Zhang";

System.Xml.XmlNamespaceManager Nsmanager = new System.Xml.XmlNamespaceManager (Doc. NameTable);
Nsmanager. AddNamespace ("Media", "http://search.yahoo.com/mrss/");

Creates a string containing an XPATH expression for evaluation.
String exprstring = String.Format ("//{0}:group", "media");

System.Xml.XmlNodeList nodelist = doc. SelectNodes (exprstring, Nsmanager);

Outstr + = "<br>media:title:" +nodelist[0]. selectSingleNode ("Media:title", Nsmanager). attributes["type"]. InnerText;





for (int i=0;i<xnl. count;i++)
//            {
Outstr + = "<br> //            }
}

I saw it at the time. GG's XML has a colon, the card is solved.
To pay the XML fragment

-<media:group>
<media:title type= "plain" >02.JPG</media:title>
<media:description type= "plain"/>
<media:keywords/>
"Yun_qi_img/02.jpg" height= "<media:thumbnail" width= "url="/>
<media:thumbnail url= "yun_qi_img/02.jpg" height= "width=" 144
<media:thumbnail url= "yun_qi_img/02.jpg" height= "the" width= "" "/>
<media:content url= "yun_qi_img/02.jpg" height= "width=" type= "image/jpeg" medium= "image"/>
<media:credit> Powertrain </media:credit>
</media:group>

XML Address: Http://picasaweb.google.com/pengpengsay/lNFxFK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.