I’m creating a node programmatically, however one of the attributes comes out differently than what I specified in the code:
XmlNode xResource = docXMLFile.CreateNode(XmlNodeType.Element, "resource", docXMLFile.DocumentElement.NamespaceURI);
XmlAttribute xRefIdentifier = docXMLFile.CreateAttribute("identifier");
XmlAttribute xRefADLCP = docXMLFile.CreateAttribute("adlcp:scormtype");
XmlAttribute xRefHREF = docXMLFile.CreateAttribute("href");
XmlAttribute xRefType = docXMLFile.CreateAttribute("type");
xRefIdentifier.Value = "RES-" + strRes;
xRefADLCP.Value = "sco";
xRefHREF.Value = dataRow["launch_url"].ToString().ToLower();
xRefType.Value = "webcontent";
xResource.Attributes.Append(xRefIdentifier);
xResource.Attributes.Append(xRefADLCP);
xResource.Attributes.Append(xRefHREF);
xResource.Attributes.Append(xRefType);
This ends up creating a line like the following. Note that ‘adlcp:scormtype’ has morphed into ‘scormtype’ which is not what I specified. Any ideas how to get it to show what I put in the CreateAttribute?
<resource identifier="RES-CDA68F64B849460B93BF2840A9487358" scormtype="sco" href="start.html" type="webcontent" />
This is probably expected behavior of this override CreateAttribute combined with saving the document:
Use another override XmlDocument.CreateAttribute to specify namespace and prefix: