Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Reomoval of name space attribute

Reply
Thread Tools

Reomoval of name space attribute

 
 
davisjoseph@postmark.net
Guest
Posts: n/a
 
      06-27-2005
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"
xmlnssi="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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-27-2005


http://www.velocityreviews.com/forums/(E-Mail Removed) 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"
> xmlnssi="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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok?? Christian Seberino Python 21 10-27-2003 04:20 PM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-24-2003 11:15 AM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-23-2003 07:07 AM
Stack space, global space, heap space Shuo Xiang C Programming 10 07-11-2003 07:30 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments