I am adding XmlElement to an existing document but an extra attribute is being added. Here is the code:
XmlNode manifest = this.getManifestNode ();
XmlElement manifestEntry = _content.CreateElement ("item", _contentPath);
XmlAttribute id = _content.CreateAttribute ("id");
id.Value = "content" + getManifestNodes ().Count;
XmlAttribute href = _content.CreateAttribute ("href");
href.Value = splitPath [splitPath.Length - 1];
XmlAttribute mediaType = _content.CreateAttribute ("media-type");
mediaType.Value = "application/xhtml+xml";
manifestEntry.Attributes.Append (id);
manifestEntry.Attributes.Append (href);
manifestEntry.Attributes.Append (mediaType);
manifest.AppendChild (manifestEntry);
and the resulting XML:
<item id="content3" href="test1.html" media-type="application/xhtml+xml" xmlns="/home/jdphenix/epubtest/test/OEBPS/content.opf" />
Where is the
xmlns="/home/jdphenix/epubtest/test/OEBPS/content.opf"
coming from? The path that it adds is the location of the document on disk, but I'm not adding it in my code (atleast, that I am aware of). Let me know if you need to know more details.
Edit: I modified my code per Filburt's suggestion and changed
XmlElement manifestEntry = _content.CreateElement ("item", _contentPath);
to
XmlElement manifestEntry = _content.CreateElement ("item");
This is a step in the right direction, but produces the following XML:
<item id="content3" href="test1.html" media-type="application/xhtml+xml" xmlns="" />