473,406 Members | 2,217 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,406 software developers and data experts.

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

Jul 20 '05 #1
1 1166


da*********@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/
Jul 20 '05 #2

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

Similar topics

6
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
2
by: Malcolm Dew-Jones | last post by:
Hello What is the correct way to associate the attributes with the tag if the tag has a name space associated with it and the attribute doesn't have a name space? i.e. <mytag
6
by: Richard | last post by:
<a href="#" name="sample">link 1</a> <a href="#" name="sample">link 2</a> Would this be invalid use of the name? If I wanted to have a function that would be acted upon by detection of the...
0
by: Marc Meermans | last post by:
While converting a schema library into a .Net class library using XSD I constantly kept running into the following error message issues by the tool: Error: Error generating classes for schema...
4
by: Paul Hadfield | last post by:
Hi, Wonder if anyone can help me on this, In DotNet2.0 I've been quite happily using the WriteAttributeString method of XmlWriter object, but have run into a problem when trying to output a...
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
7
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
How do I split a title attribute value into lines within the source code so that the paragraph gets reassembled by the browser when it is being displayed? Microsoft Internet Explorer 7 preserves...
13
by: jtric | last post by:
Very new to XML/XSL, so please forgive me if this is an incredibly simple question. I've been pulling my hair out over this for several days now. I'm working on an internal application that takes...
5
by: John Gordon | last post by:
My XSLT files have many occurrences of this general pattern: <a> <xsl:attribute name="href"> <xsl:value-of select="xyz" /> </xsl:attribute> </a> When I execute an XSL transform, the...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.