111,129
社区成员
发帖
与我相关
我的任务
分享
XmlDocument doc = new XmlDocument();
XmlDeclaration xmlDecl = doc.CreateXmlDeclaration("1.0", "", "");
doc.AppendChild(xmlDecl);
XmlElement xeRoot = doc.CreateElement("mets",":mets");
xeRoot.Prefix = "METS";
XmlAttribute xa = doc.CreateAttribute("xsi:schemaLocation", "xsi");
xa.Value = "http://www.loc.gov/METS/
http://www.loc.gov/standards/mets/mets.xsd";
xa.Prefix = "xsi";
xeRoot.Attributes.Append(xa);
doc.AppendChild(xeRoot);
doc.Save(xmlpath);
<?xml version="1.0"?>
<METS:mets
d1p1:schemaLocation = "http://www.loc.gov/METS/
http://www.loc.gov/standards/mets/mets.xsd"
xmlns:d1p1 = "xsi"/>
XmlDocument doc = new XmlDocument();
string ns = doc.NamespaceURI;
XmlDeclaration xmlDecl = doc.CreateXmlDeclaration("1.0", "", "");
doc.AppendChild(xmlDecl);
XmlElement xeRoot = doc.CreateElement("mets", ":mets");
xeRoot.Prefix = "METS";
XmlAttribute xa = doc.CreateAttribute("schemaLocation", "http://www.w3.org/2000/xmlns");
xa.Value = @"http://www.loc.gov/METS/
http://www.loc.gov/standards/mets/mets.xsd";
xa.Prefix = "xsi";
xeRoot.Attributes.Append(xa);
doc.AppendChild(xeRoot);