Menu

This name may not contain the '#' character

Seldo
2005-08-17
2013-03-13
  • Seldo

    Seldo - 2005-08-17

    When using this library, when attempting to evaluate the expression "//a" I get the following error message from IE:

    "This name may not contain the '#' character:
    -->#<--comment"

    Does anybody know where this error message comes from? Is it a bug in IE or what?

     
    • Evan Kirkconnell

      I got the same error, and here's a little more info(see bottom for solution):
      Line 385:
      document._XPathMsxmlDocumentHelper.getDom()    This name may not contain the '#' character:-->#<--comment    Error

      if (result._isNodeSet)
      {
          result._domResult = document._XPathMsxmlDocumentHelper.getDom().selectNodes(expression);
      }
      else
      {
          result._domResult = true;
          result._textResult = document._XPathMsxmlDocumentHelper.getTextResult(expression);
      }

      Here's my code:
      var nodes = document.evaluate("descendant::*[self::input or self::textarea or self::select]/@name", newNode, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
      var item;
      while(item = nodes.iterateNext()){   
                     
      }

      I know it's been forever since you posted, but for the record...  I found this method on the old website, and it worked for me:

      var nodes = document.evaluate("descendant::*[self::input or self::textarea or self::select]/@name", newNode, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
      var item;
      for (var i=0; i<nodes.snapshotLength; i++){
          item = nodes.snapshotItem(i);
      }
      --Evan

       
    • Tom Ukmn

      Tom Ukmn - 2006-12-20

      These will work but are not exhustively tested.

      In the load node function of _XPathMsxmlDocumentHelper
      either strip comments out

      if( node.nodeType == 8 ){
      //do nothing
      }else ...

      or rewrite them

      ...
      var domNode;
      if(node.nodeType == 8){
          domNode = dom.createComment(node.nodeValue);
          domParentNode.appendChild(domNode);
      }else{
          domNode = dom.createElement(node.nodeName.toLowerCase());
          domParentNode.appendChild(domNode);
          loadAttributes(dom, domNode, node);
      }
      var length = node.childNodes.length;
      ...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.