I'm using XmlWriter
and I'm struggling to create the following XML tag.
<mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0_idx.xsd" version="1.1">
I have the following:
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter xmlWriter = XmlWriter.Create(xmlFilePath, settings);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("mzML", "xmlns", @"http://psi.hupo.org/ms/mzml");
xmlWriter.WriteAttributeString("xsi", "xmlns", @"http://www.w3.org/2001/XMLSchema-instance");
xmlWriter.WriteAttributeString("schemaLocation", "xsi", @"http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd");
xmlWriter.WriteAttributeString("version", "1.1");
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Close();
which results in the following:
<mzML:xmlns p1:xsi="http://www.w3.org/2001/XMLSchema-instance" p2:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" version="1.1.0" xmlns:p2="xsi" xmlns:p1="xmlns" xmlns:mzML="http://psi.hupo.org/ms/mzml">
The documentation is confusing me; I've tried lots of variations of the above code but can't seem to get anywhere close to my target XML tag.
Can anybody please help?
(P.S. I need to use XmlWriter
due to the size of the XML files I need to create.)