attributes.remove

Discussion in 'XML' started by sam.stamport@sbcglobal.net, Aug 16, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

  2. * 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: · 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/
     
    Bjoern Hoehrmann, Aug 16, 2005
    #2
    1. Advertising

  3. Sam Stamport Guest

    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 ***
     
    Sam Stamport, Aug 17, 2005
    #3
  4. * 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:msdn.microsoft.com XmlNamespaceManager
    lists various articles on this subject.
    --
    Björn Höhrmann · mailto: · 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/
     
    Bjoern Hoehrmann, Aug 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max
    Replies:
    1
    Views:
    506
    Joe Kesselman
    Sep 22, 2006
  2. P4trykx
    Replies:
    2
    Views:
    1,857
    bruce barker
    Jan 31, 2007
  3. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    389
    Bruno Desthuilliers
    Jun 20, 2007
  4. Kyle Schmitt
    Replies:
    3
    Views:
    210
    Kyle Schmitt
    Jul 24, 2007
  5. Jayden
    Replies:
    16
    Views:
    548
    Steven D'Aprano
    Sep 29, 2012
Loading...

Share This Page