472,096 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

attributes.remove

Hello,

In my C# program I execute an attributes remove to remove all
attributes in the following root node.

<xtvd xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:TMSWebServices">

All attributes are removed EXCEPT

xmlns="urn:TMSWebServices"

What am I doing wrong or is there a workaround?

Thanks

Aug 16 '05 #1
3 2993
* sa**********@sbcglobal.net wrote in comp.text.xml:
In my C# program I execute an attributes remove to remove all
attributes in the following root node.

<xtvd xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:TMSWebServices">

All attributes are removed EXCEPT

xmlns="urn:TMSWebServices"

What am I doing wrong or is there a workaround?


The "xmlns" attribute (as well as xmlns:* attributes) are special
attributes that declare the default namespace and namespace pre-
fixes. In the example above you have an element 'xtvd' in the
'urn:TMSWebServices' namespace, if you remove the xmlns "attribute"
you would essentially rename the element, so that's what you would
have to do in order to get rid of them. That's typically not very
useful though, applications would no longer recognize the elements
in the document.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Aug 16 '05 #2
I understand what you are saying.

The odd thing is that when I leave any attributes in the root node, I
cannot read any of the elements or attributes in the XML file using
XPathNavigator/XPathNodeIterator. When I manually remove everything in
the root node except the name <xtvd> everything works just fine.

I am using C# with Visual Studio 2003. Maybe there's something quirky
about .NET?

I cannot find a rename method. Is there some other way I can work
around this problem?

*** Sent via Developersdex http://www.developersdex.com ***
Aug 17 '05 #3
* Sam Stamport wrote in comp.text.xml:
I understand what you are saying.

The odd thing is that when I leave any attributes in the root node, I
cannot read any of the elements or attributes in the XML file using
XPathNavigator/XPathNodeIterator. When I manually remove everything in
the root node except the name <xtvd> everything works just fine.


You need to use an XmlNamespaceManager here, declare a prefix for the
xmlns="urn:TMSWebServices" namespace and use namespace prefixes in the
XPath expressions, so instead of "/xtvd" you would use "/prefix:xtvd".

http://www.google.com/search?q=+site...mespaceManager
lists various articles on this subject.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Aug 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mike | last post: by
8 posts views Thread by Gerry Viator | last post: by
7 posts views Thread by localhost | last post: by
4 posts views Thread by Craig G | last post: by
1 post views Thread by Gérard Talbot | last post: by
23 posts views Thread by Frank Millman | last post: by
reply views Thread by leo001 | last post: by

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.