像下面的节点我怎么读出url的值来
<media:thumbnail url="http://static.flickr.com/106/251336449_ddbc6aadf3_s.jpg" height="75" width="75" />我现在只能读下面这个节点一样的东西
<title>Luly Yang Couture</title> 

解决方案 »

  1.   

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml("<media:thumbnail url=\"http://static.flickr.com/106/251336449_ddbc6aadf3_s.jpg\" height=\"75\" width=\"75\" xmlns:media='http://dotnet.aspx.cc/'/>");
    System.Xml.XmlNamespaceManager nr = new XmlNamespaceManager(xmlDoc.NameTable);nr.AddNamespace("media", "http://dotnet.aspx.cc/");
    XmlNode n = xmlDoc.SelectSingleNode("/media:thumbnail/@url", nr);
    Response.Write(n.Value);
      

  2.   

    带名称空间的,一定要使用XmlNamespaceManager 进行名称空间的管理
      

  3.   

    我想直接给一个RSS地址就能读出<media:thumbnail url="http://static.flickr.com/106/251336449_ddbc6aadf3_s.jpg" height="75" width="75" />这个节点里的url应该怎么做啊
      

  4.   

    从rss地址得到xmlDOM,你只需要知道media:的名称空间即可。其它做法类似
      

  5.   

    我想直接给一个RSS地址就能读出所有的<media:thumbnail节点下的Uurl
    到底应该怎么做
      

  6.   

    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">  protected void Page_Load( object sender, EventArgs e )
      {
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        doc.Load("http://api.flickr.com/services/feeds/photos_public.gne?id=44124424463@N01&format=rss_200");    System.Xml.XmlNamespaceManager nr = new System.Xml.XmlNamespaceManager(doc.NameTable);
        nr.AddNamespace("mxh", "http://search.yahoo.com/mrss");
        System.Xml.XmlNodeList ns = doc.SelectNodes("/rss/channel/item/mxh:content", nr);
        foreach (System.Xml.XmlNode n in ns)
        {      
          Response.Write("<br><img src='" + n.Attributes["url"].Value + "' width='" + n.Attributes["width"].Value + "' height='" + n.Attributes["height"].Value + "'>");
        }
      }
    </script>
      

  7.   

    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">  protected void Page_Load( object sender, EventArgs e )
      {
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        doc.Load("http://api.flickr.com/services/feeds/photos_public.gne?id=44124424463@N01&format=rss_200");    System.Xml.XmlNamespaceManager nr = new System.Xml.XmlNamespaceManager(doc.NameTable);
        nr.AddNamespace("mxh", "http://search.yahoo.com/mrss");
        System.Xml.XmlNodeList ns = doc.SelectNodes("/rss/channel/item/mxh:content", nr);
        int i = 1;
        Response.Write("<table><tr>");
        foreach (System.Xml.XmlNode n in ns)
        {  
       
          Response.Write("<td><img src='" + n.Attributes["url"].Value + "' width='" + n.Attributes["width"].Value + "' height='" + n.Attributes["height"].Value + "'></td>");
          if(i == 3)
          {
           Response.Write("</tr><tr>");
          }
          i++;
         if(i>6) break;
        }
        Response.Write("</tr></table>");
      }
    </script>