csharp System.Xml.XmlElement.HasAttributes类(方法)实例源码

下面列出了csharp System.Xml.XmlElement.HasAttributes 类(方法)源码代码实例,从而了解它的用法。

作者:.NET开发    项目:System.Xm   
//引入命名空间
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Remove all attributes from the root element.
    if (root.HasAttributes)
      root.RemoveAllAttributes();
    
    Console.WriteLine("Display the modified XML...");
    Console.WriteLine(doc.InnerXml);
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号