使用具有名称空间和前缀的XmlWriter的c#XML文件格式
以下是我正在寻找的所需XML格式:使用具有名称空间和前缀的XmlWriter的c#XML文件格式,c#,xml,xmlwriter,C#,Xml,Xmlwriter,以下是我正在寻找的所需XML格式: <mf:package xmlns="urn:x-lexisnexis:content:manifest:global:1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:x-lexisnexis:content:manifest:global:1 sch_manifest.xsd&quo
<mf:package
xmlns="urn:x-lexisnexis:content:manifest:global:1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:x-lexisnexis:content:manifest:global:1 sch_manifest.xsd"
mf:mf="urn:x-lexisnexis:content:manifest:global:1">
我在这里做错了什么?假设您正在编写,您想要的XML格式不正确:
上传到,你会得到一个错误
XML文档中的错误:1:250元素“mf:package”的前缀“mf”未绑定
具体地说,这里定义一个元素
,区别在于:mf:mf=“urn:x-lexisnexis:content:manifest:global:1”这是必需的。我得到:xmlns:mf=“urn:x-lexisnexis:content:manifest:global:1”您所需的XML格式不正确。上传到,您将得到一个错误,XML文档中的错误:1:250元素“mf:package”的前缀“mf”未绑定。
具体来说,您定义了一个元素@dbc:您的注释可能是一个答案,IMHO。
需要的更多内容^^
<mf:package
xmlns="urn:x-lexisnexis:content:manifest:global:1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:x-lexisnexis:content:manifest:global:1 sch_manifest.xsd"
xmlns:mf="urn:x-lexisnexis:content:manifest:global:1">
using (XmlWriter writer = XmlWriter.Create(parentPathPackage + packageID + "_man.xml", settings))
{
writer.WriteStartElement("mf", "package", "urn:x-lexisnexis:content:manifest:global:1");
writer.WriteAttributeString("", "xmlns", null, "urn:x-lexisnexis:content:manifest:global:1");
writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString("xsi", "schemaLocation", null, "urn:x-lexisnexis:content:manifest:global:1 sch_manifest.xsd");