![]() |
Reomoval of name space attribute
Hi,
I'm using Xerces C++ API for XML operations. I need to remove the XML namespace attribute from this type of XML doc, <?xml version="1.0" encoding="UTF-8"?> <root xmlns="http://skies.net/schema/sky" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://skies.net/schema/sky http://http://skies.net/schema/Schema.xsd"> ............ </root> need to be <?xml version="1.0" encoding="UTF-8"?> <root > ......... </root> I tried to use removeAttributeNS() & removeAttribute()functions ; but I'm not able to remove the attribute fully. I think I'm missing something.Can any one provide me a small code snippet that can do this opeartion. I'm newbie to this Xerces API. Thanks & Regards |
Re: Reomoval of name space attribute
davisjoseph@postmark.net wrote: > I'm using Xerces C++ API for XML operations. I need to remove the XML > namespace attribute from this type of XML doc, > > <?xml version="1.0" encoding="UTF-8"?> > <root xmlns="http://skies.net/schema/sky" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://skies.net/schema/sky > http://http://skies.net/schema/Schema.xsd"> > ........... > </root> > > need to be > <?xml version="1.0" encoding="UTF-8"?> > <root > > ........ > </root> > > I tried to use removeAttributeNS() & removeAttribute()functions ; but > I'm not able to remove the attribute fully. I think I'm missing > something.Can any one provide me a small code snippet that can do this > opeartion. It is not possible to change the namespace associated with a node after its creation, you need to create a new node (element in this case) that is in no namespace and then replace the original node. JavaScript pseudo-code: function changeElement (oldElement, newTagName) { var newElement = oldElement.ownerDocument.createElement(newTagName) ; oldElement.parentNode.replaceChild(newElement, oldElement); while (oldElement.hasChildNodes()) { newElement.appendChild(oldElement.firstChild); } } changeElement(xmlDocument.documentElement, 'root'); -- Martin Honnen http://JavaScript.FAQTs.com/ |
| All times are GMT. The time now is 04:06 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.