I'm building an xml file using XDocument
XDocument single = new XDocument(
new XDeclaration("1.0", "UTF-8", "true"),
new XElement(_namespace + "vcards",
XElement.Parse(BuildCardEntry(contact))));
Inside BuildCardEntry(contact)
I'm adding the namespace to every XElement
too. But my code pruduces this
<vcards xmlns="urn:ietf:params:xml:ns:vcard-3.0">
<vcard xmlns="urn:ietf:params:xml:ns:vcard-3.0">
insted of this
<vcards xmlns="urn:ietf:params:xml:ns:vcard-3.0">
<vcard>
Does somebody know, how to solve this?
保存xml时,请使用SaveOptions.OmitDuplicateNamespaces
参数。
single.Save(..., SaveOptions.OmitDuplicateNamespaces);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.