XML Annoyance

  • Thread starter Thread starter plank
  • Start date Start date
P

plank

Hey,

I am using C# to create an XML file in memory and then save it to a file. Everything is working
great apart from one thing which I can't figure out! :(

I have a few namespaces.. one is causing problems:

XmlDocument MANIFEST_XML_DOC = new XmlDocument();
XmlElement oManifest = MANIFEST_XML_DOC.CreateElement("manifest");

oManifest.SetAttribute("xmlns", "http://www.imsproject.org/xsd/imscp_rootv1p1p2");
oManifest.SetAttribute("xmlns:adlcp", "http://www.adlnet.org/xsd/adlcp_rootv1p2");
oManifest.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
oManifest.SetAttribute("xsi:schemaLocation",
"http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd
http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd
http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd");

MANIFEST_XML_DOC.AppendChild(oManifest);
MANIFEST_XML_DOC.Save("imsmanifest.xml");

When the XML file is saves the schmeaLocation doesn't have the "xsi:" prefix.

Anybody know why??

Please help!

Thanks in adavce,

Anil
 
You're welcome. I ran across the exact same issue a while back -- I guess
you're doing some SCORM stuff. Tried using XmlNamespaceManager but it
wouldn't allow changing the value of "xmlns" -- it's reserved for use by
XML. Might be another way, but this worked for me.
 
Back
Top