C# C中Xml文件的xmlns问题#
因为我不理解C# C中Xml文件的xmlns问题#,c#,xml,xml-namespaces,C#,Xml,Xml Namespaces,因为我不理解xmlns、xmlns:xsd和xmlns:xsi的关键字,所以我发布了这个问题 我找到了XpathNavigatorMoveToChile方法的一个示例,并附上了xml文件示例 XmlDocument document = new XmlDocument(); document.Load("contosoBooks.xml"); XPathNavigator navigator = document.CreateNavigator(); navigator.MoveToChild
xmlns
、xmlns:xsd
和xmlns:xsi
的关键字,所以我发布了这个问题
我找到了XpathNavigatorMoveToChile
方法的一个示例,并附上了xml文件示例
XmlDocument document = new XmlDocument();
document.Load("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();
navigator.MoveToChild("bookstore", "http://www.contoso.com/books");
MSDN中的示例Xml文件
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://www.contoso.com/books">
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
感谢您的回复。请查看此
基本上,您可以为XML名称空间定义一个前缀,以使其更易于使用:
<Equipment
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<License licenseId="" licensePath=""/>
<xsd:element ..... xsi:nil="true" />
属于默认命名空间的元素可能是您最需要的元素,因此您可以定义一个不带前缀的XML命名空间-默认命名空间:
<Equipment
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.yourcompany.com/your/default/namespace" >
<License licenseId="" licensePath=""/>
<xsd:element ..... xsi:nil="true" />
现在,XML中没有特定前缀的所有元素(这里是
标记)都是默认XML命名空间的一部分。请查看此项
基本上,您可以为XML名称空间定义一个前缀,以使其更易于使用:
<Equipment
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<License licenseId="" licensePath=""/>
<xsd:element ..... xsi:nil="true" />
属于默认命名空间的元素可能是您最需要的元素,因此您可以定义一个不带前缀的XML命名空间-默认命名空间:
<Equipment
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.yourcompany.com/your/default/namespace" >
<License licenseId="" licensePath=""/>
<xsd:element ..... xsi:nil="true" />
现在,XML中没有特定前缀的所有元素(这里是
标记)都是默认XML命名空间的一部分