Different results selecting HTML elements with XPath in Firefox and Internet Explorer

后端 未结 10 830
-上瘾入骨i
-上瘾入骨i 2021-01-18 10:34

I\'m trying to select a specific HTML element in a document, for firefox i just use:

xpathobj = document.evaluate(xpath, document, null,
               XPath         


        
10条回答
  •  长情又很酷
    2021-01-18 11:19

    Instead of doing

    xmlDoc.load(document); 
    

    try

    xmlDoc.loadXML(document.body.outerHTML)
    

    This would only really work if your your HTML document is formatted to XHTML standards. Also, the BODY tag would be the root node, so you would have to change your XPATH to "/BODY/DIV[9]/DIV[2]"

提交回复
热议问题