0

我正在编写以下代码以向现有 xml 添加标题标签。

            String pagemetadata = curPage.Metadata.OuterXml;
            XmlDocument pageMeta = new XmlDocument();
            pageMeta.LoadXml(pagemetadata);

            XmlNode Metadata = pageMeta.FirstChild as XmlNode;
            XmlNode headingNode = pageMeta.CreateNode(XmlNodeType.Element, "heading", null);
            headingNode.InnerText = HTML_BrowserTitle;
            Metadata.AppendChild(headingNode);

我可以添加标签,如下所示。但是我怎样才能从标签中删除 xmlns="" 呢?

<title xmlns="">    </title> 
4

1 回答 1

0

This usually happens when the namespace of the document is different to the namespace of the element. Try creating the XML Node with CreateNodeNS instead of CreateNode, and make sure it is in the same namespace as its parent/main document.

于 2012-09-07T11:01:38.800 回答