![](/img/trans.png)
[英]XDocument: get the first child element of type 'a' or 'b'
[英]XDocument Namespace on root and first child
我正在使用XDocument構建xml文件
XDocument single = new XDocument(
new XDeclaration("1.0", "UTF-8", "true"),
new XElement(_namespace + "vcards",
XElement.Parse(BuildCardEntry(contact))));
在BuildCardEntry(contact)
內部,我也將命名空間添加到每個XElement
。 但是我的代碼可以做到這一點
<vcards xmlns="urn:ietf:params:xml:ns:vcard-3.0">
<vcard xmlns="urn:ietf:params:xml:ns:vcard-3.0">
對此感興趣
<vcards xmlns="urn:ietf:params:xml:ns:vcard-3.0">
<vcard>
有人知道,如何解決這個問題?
保存xml時,請使用SaveOptions.OmitDuplicateNamespaces
參數。
single.Save(..., SaveOptions.OmitDuplicateNamespaces);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.