Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does .NET XML append an xlmns attribute to XmlElements I add to a document? Can I stop it?
    primarykey
    data
    text
    <p>I am adding XmlElement to an existing document but an extra attribute is being added. Here is the code: </p> <pre><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); </code></pre> <p>and the resulting XML: </p> <pre><code>&lt;item id="content3" href="test1.html" media-type="application/xhtml+xml" xmlns="/home/jdphenix/epubtest/test/OEBPS/content.opf" /&gt; </code></pre> <p>Where is the </p> <pre><code>xmlns="/home/jdphenix/epubtest/test/OEBPS/content.opf" </code></pre> <p>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. </p> <p>Edit: I modified my code per Filburt's suggestion and changed</p> <pre><code>XmlElement manifestEntry = _content.CreateElement ("item", _contentPath); </code></pre> <p>to</p> <pre><code>XmlElement manifestEntry = _content.CreateElement ("item"); </code></pre> <p>This is a step in the right direction, but produces the following XML: </p> <pre><code>&lt;item id="content3" href="test1.html" media-type="application/xhtml+xml" xmlns="" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload