removing elements in namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graham

    removing elements in namespace

    Hi all,

    I'm trying to clean up the output from Word that has been
    pasted into a textarea. I'm purging much of the html (all
    styles, attributes etc) and would also like to remove things
    like vector graphics. To do this I want to simply drop all
    elements (or their children) which are in any namespace other
    than the default: all the microsoft-specific o:p, v:drawLine, etc
    tags. But I can't persuade javascript to even see the namespaces!
    I'm using IE5.5 (this needs to work on browsers that old, but no
    older).

    Has anyone done this before? Is there some simple step I might
    be missing? Given an element variable, could you give me a line
    or two of code just to display the namespace tag?

    Thanks

    Graham
  • Martin Honnen

    #2
    Re: removing elements in namespace



    Graham wrote:

    [color=blue]
    > Has anyone done this before? Is there some simple step I might
    > be missing? Given an element variable, could you give me a line
    > or two of code just to display the namespace tag?[/color]

    With IE 5 and later on Win elements have two properties
    scopeName
    giving the prefix and
    tagUrn
    giving the Namespace URN for example

    <html lang="en"
    xmlns:gods="htt p://example.com/2004/09/gods">
    <head>
    <title>scopeNam e and tagUrn</title>
    <script type="text/javascript">
    function testNamespacePr operties () {
    var elements = document.body.a ll;
    if (elements) {
    var result = '';
    for (var i = 0; i < elements.length ; i++) {
    var element = elements[i];
    result += 'tagName: ' + element.tagName + '; ';
    result += 'scopeName: ' + element.scopeNa me + '; ';
    result += 'tagUrn: ' + element.tagUrn;
    result += '\r\n';
    }
    alert(result);
    }
    }

    window.onload = function (evt) {
    testNamespacePr operties();
    };
    </script>
    </head>
    <body>
    <p id="p1">
    This is a HTML paragraph.
    </p>
    <div>
    <gods:GOD id="GOD">Kibo</gods:GOD>
    </div>
    </body>
    </html>


    --

    Martin Honnen

    Comment

    • Martin Honnen

      #3
      Re: removing elements in namespace



      Martin Honnen wrote:
      [color=blue]
      >
      >
      > Graham wrote:
      >
      >[color=green]
      >> Has anyone done this before? Is there some simple step I might
      >> be missing? Given an element variable, could you give me a line
      >> or two of code just to display the namespace tag?[/color]
      >
      >
      > With IE 5 and later on Win elements have two properties
      > scopeName
      > giving the prefix and
      > tagUrn
      > giving the Namespace URN[/color]

      Documentation is here



      --

      Martin Honnen

      Comment

      Working...