如何添加xml命名空间 [英] how to add xml namespaces
本文介绍了如何添加xml命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个提要(它的片段)需要看起来完全像这样:
This feed (snippit of it) needs to look exactly like this:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
我要在这个 C# 代码中添加什么来添加额外的 xmlns、xsi 垃圾:
what do I add to this C# code to add that extra xmlns, xsi junk:
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
如果没有它,这个供稿就会被拒绝--
this feed is rejected without it--
推荐答案
试试这个:
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString(
"xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString(
"xsi", "noNamespaceSchemaLocation", null, "amzn-envelope.xsd");
...
writer.WriteEndElement();
这篇关于如何添加xml命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文