【发布时间】:2012-06-22 14:56:19
【问题描述】:
您好,我目前在解析没有任何命名空间的 Xml 字符串并添加到具有命名空间的现有 XElement 时遇到问题。
我的代码:
XElement elem = root.Element(xs + "methodCall");
if (elem != null)
{
XElement e = XElement.Parse(this.MethodCallXML);
elem.Add(e);
}
结果:
<methodCall>
<methodCall service="activity" method="activityDeleteComment" xmlns="">
<espSessionState>espSessionState1</espSessionState>
<traceFlowCode>true</traceFlowCode>
<params>
<commentID>http://uri1</commentID>
<isPermanentDelete>false</isPermanentDelete>
</params>
</methodCall>
</methodCall>
我的问题是 xmlns="" 我无法弄清楚如何使用 parse 方法创建节点并给它一个默认的命名空间来使用。
有什么办法吗?
【问题讨论】:
标签: c# xml xml-parsing linq-to-xml xml-namespaces