473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Stripping namespace

Given an XmlNode with namespace (NamespaceURI has a value), I want to be
able to make a clone of it (XmlNode.CloneNode) but without the namespace.
How can I strip the namespace from a node?
Jun 27 '08 #1
1 1466
Clive Dixon wrote:
Given an XmlNode with namespace (NamespaceURI has a value), I want to be
able to make a clone of it (XmlNode.CloneNode) but without the namespace.
How can I strip the namespace from a node?
If the namespace is different then the new node is a not a clone of the
old node.
What you can do is create a new node in a different namespace
respectively in no namespace:

XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<foo xmlns=""http://example.com/ns1""/>");
XmlNode foo1 = doc.DocumentElement;
XmlNode foo2 = doc.CreateNode(foo1.NodeType, foo1.LocalName, "");
doc.ReplaceChild(foo2, foo1);

Note that if the old node has any child elements then you need to apply
the same approach to the child elements as well as those inherit the
namespace.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Margaret MacDonald | last post by:
I've been going mad trying to figure out how to do this--it should be easy! Allow the user to enter '\_sometext\_', i.e., literal backslash, underscore, some text, literal backslash, underscore...
3
by: Steveo | last post by:
I am currently stripping HTML from a string with the following code. (I know it's not the best way to strip HTML but bear with me) re.compile("<.*?>") I wanted to allow all H1 and H2 tags so i...
2
by: Patrick | last post by:
Hello, after learning that I was taking a class in VB.NET, I have been drafted to solve all my companies VB/scripting problems - hey, I should know everything; I've already taken 6 classes ;) I...
1
by: Barry | last post by:
A buffer containing an xml document with a default namespace is fed to an XmlValidatingReader. The reader loads a schema targeting the same namespace, and is passed to an XslTransform. Because...
16
by: John Smith | last post by:
Hi all Why doesn't this seem to work? void stripnl(char *sz) { char *nl; nl = strchr(sz, '\n'); if (nl) {
4
by: Lu | last post by:
Hi, i am currently working on ASP.Net v1.0 and is encountering the following problem. In javascript, I'm passing in: "somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query...
4
by: Spondishy | last post by:
Hi, I'm looking for help with a regular expression and c#. I want to remove all tags from a piece of html except the following. <a> <b> <h1> <h2>
7
by: Edward Elliott | last post by:
I'm looking for the "best" way to strip a large set of chars from a filename string (my definition of best usually means succinct and readable). I only want to allow alphanumeric chars, dashes,...
2
by: delyan.nestorov | last post by:
Hi All, I have the following problem: I read lines from DXF file ( AutoCAD format file ). Then I need to remove white spaces from lines to continue working on data i.e. converting from string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.