在我的XML文件中包含xmlns [英] Including xmlns in my XML file
本文介绍了在我的XML文件中包含xmlns的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在xDocument中添加以下两行?
How can I add the two lines below in my xDocument?
我正在使用Xelements和Xattributes创建一个xml文件.你能告诉我如何将其包含在我的xml文件中吗?
I am creating an xml file with Xelements and Xattributes. Can you tell my how can I include this in my xml file please?
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
由于某种原因,我在下一个标签上得到了xmlns =".示例如下所示.
I am getting xmlns="" on the next tag for some reason. A sample is shown below.
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<FirstTag xmlns="">
推荐答案
XNamespace ns = "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03";
var doc = new XElement(ns + "Document",
new XAttribute(XNamespace.Xmlns + "xsi",
"http://www.w3.org/2001/XMLSchema-instance"));
结果:
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" />
这篇关于在我的XML文件中包含xmlns的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文