我开发了以下代码来生成xElement
(C# 语言):
new XElement("Transmission",
new XAttribute(XNamespace.Xmlns.GetName("xmlns").LocalName, "http://www.irs.gov/efile"),
new XAttribute(XNamespace.Xmlns + "xsi", xsi),
new XAttribute(xsi + "schemaLocation", schemaLocation),
........
三个命名空间声明如下:
private static XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
private static XNamespace schemaLocation = XNamespace.Get("http://www.irs.gov/efile ./ExtendedCommon/Transmission.xsd");
private static XNamespace xmlnsLocation = XNamespace.Get("http://www.irs.gov/efile");
但是,当我从中生成 xml 时,出现以下错误:
The prefix '' cannot be redefined from '' to 'http://www.irs.gov/efile' within the same start element tag.
有人可以帮忙吗?