我试图为OpenClinica编写一个XML文件,这是一个使用CDISC表示的临床试验平台。我的问题是,当我试图用XmlWriter编写XML的第一个元素时,我有一个例外:
An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but
was not handled in user code
Additional information: The prefix '' cannot be redefined from '' to
'http://www.cdisc.org/ns/odm/v1.3' within the same start element tag.这是我想要的文件:
<ODM xmlns="http://www.cdisc.org/ns/odm/v1.3"
xmlns:OpenClinica="http://www.openclinica.org/ns/odm_ext_v130/v3.1"
xmlns:OpenClinicaRules="http://www.openclinica.org/ns/rules/v3.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
FileOID="testD20161121140900+0000"
Description="test"
CreationDateTime="2016-11-21T14:09:00+00:00"
FileType="Snapshot"
ODMVersion="1.3"
xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0-OC2-0.xsd">这是我的密码:
StringWriter swriter = new StringWriter();
XmlWriter writer = XmlWriter.Create(swriter);
writer.WriteStartElement("ODM");
writer.WriteAttributeString("xmlns", "http://www.cdisc.org/ns/odm/v1.3");
writer.WriteAttributeString("xmlns", "OpenClinica", null, "http://www.openclinica.org/ns/odm_ext_v130/v3.1");
writer.WriteAttributeString("xmlns","OpenClinicaRules",null, "http://www.openclinica.org/ns/rules/v3.1");
writer.WriteEndElement();
writer.Close();
return swriter.ToString();如果我只尝试编写" xmlns :OpenClinica“和"xmlns:OpenClinicaRules”属性,它会进行得很好,但是当我尝试编写xmlns属性时会出现问题。
这里有什么问题吗?
发布于 2016-11-22 10:56:11
尝试以下几点:
writer.WriteStartElement("","ODM","http://www.cdisc.org/ns/odm/v1.3");https://stackoverflow.com/questions/40739611
复制相似问题