Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > attributes.remove

Reply
Thread Tools

attributes.remove

 
 
sam.stamport@sbcglobal.net
Guest
Posts: n/a
 
      08-16-2005
Hello,

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

<xtvd xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="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

 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      08-16-2005
* http://www.velocityreviews.com/forums/(E-Mail Removed) wrote in comp.text.xml:
>In my C# program I execute an attributes remove to remove all
>attributes in the following root node.
>
><xtvd xmlnssd="http://www.w3.org/2001/XMLSchema"
>xmlnssi="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 · (E-Mail Removed) · 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/
 
Reply With Quote
 
 
 
 
Sam Stamport
Guest
Posts: n/a
 
      08-17-2005
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 ***
 
Reply With Quote
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      08-17-2005
* 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 "/prefixtvd".

http://www.google.com/search?q=+site...mespaceManager
lists various articles on this subject.
--
Björn Höhrmann · (E-Mail Removed) · 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/
 
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




Advertisments