I do not know how to remove the schema details from an
XmlDocument. I have loaded my Xml document as follows:
XmlDocument doc = new XmlDocument();
doc.load("test.xml");
and I would like to remove the following details from my
XmlDocument:
xmlns="http://localhost/reportdownload/testSchema.xml
Is this possible??
The entire xml document is as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Properties>
<DefaultValues
xmlns="http://localhost/reportdownload/testSchema.xml">
<Project >
<ProxyEnable type="bool" value="False"/>
<ProxyName type="string" value=""/>
<ProxyPort type="long" value="80"/>
<KeepOneRecycledFile type="bool"
value="false"/>
<RecycleSize type="long" value="20"/>
<LogPath type="string"
value="(automatic)"/>
<LogEnable type="bool" value="true"/>
<CheckRobots type="bool" value="True"/>
<UseAbortiveTcpClose type="bool"
value="true"/>
<SocketTimeout type="long" value="120"/>
</Project>
<DynamicTest >
<Language type="string" value="VBScript"/>
<NumberOfThreads type="long" value="1"/>
<FollowRedirects type="bool" value="True"/>
<RedirectDepth type="long" value="15"/>
</DynamicTest>
</DefaultValues>
Thanks for any help,
Sharon
There is no easy way to 'remove' the namespace from an element or attribute.
The only way to do this is to write code to walk a tree and create a
duplicate tree with different namespace uris.
You could also write a fairly simple XSLT stylesheet to transform it. the
main guts would be:
<xsl:template match="*" mode="RemoveNamespace">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*"/>
</xsl:element>
</xsl:template>
This assumes that no attribute is in a namespace (which is typical, but
academic to change if it's not true).
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Sharon" <sharon...@totalise.net> wrote in message
news:011301c2cdfc$40a62c40$d2f82ecf@TK2MSFTNGXA09...
> You could also write a fairly simple XSLT stylesheet to transform it. the
> main guts would be:
>
> <xsl:template match="*" mode="RemoveNamespace">
> <xsl:element name="{local-name()}">
> <xsl:copy-of select="@*"/>
<!-- I believe you forgot apply-templates here -->
<xsl:apply-teampltes/>
> </xsl:element>
> </xsl:template>
Also XSL FAQ has full copy of such a stylesheet:
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d4932e1708.
--
Oleg Tkachenko
Multiconn Technologies, Israel
XmlDocument doc = new XmlDocument();
doc.Load("yourxmlfile.xml");
System.IO.MemoryStream mem = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8);
doc.WriteContentTo(writer);
writer.Flush();
mem.Position = 0;
XmlTextReader reader = new XmlTextReader(mem);
//The reader will not support namespaces, removing
//the xmlns from any namespace bound node
reader.Namespaces = false;
doc.Load(reader);
The contents of doc should contain only the local names of all of the nodes
without namespace bindings.
Kirk Allen Evans
Author, "XML And ASP.NET", New Riders Publishing
www.xmlandasp.net
Read my web log at http://www.dotnetweblogs.com/kaevans
"Oleg Tkachenko" <ol...@multiconn.com> wrote in message
news:ubHtQAwzCHA.1620@TK2MSFTNGP11...