Forum Discussion

jesse2's avatar
jesse2
Occasional Contributor
7 years ago

Internet Explorer outerHTML and innerHTML missing closing tags on table objects <th> and <td>

I am trying to convert HTML tables to XML, but when performing the conversion on a Table object in IE, I get an error about tags not matching. The function I'm running is:

    while True:
      if (ReportObj.VisibleOnScreen == True):
        XMLdoc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
        xmlstring = ReportObj.outerHTML
        XMLdoc.loadXML(xmlstring) # This is the part of the function throwing the error below
        return XMLdoc

 

The exact error in TestComplete is: End tag 'tr' does not match the start tag 'th'

 

In Chrome, FF, and Edge this function works fine, only IE gives me the problem. After some digging, I've tracked it down to the outerHTML and innerHTML properties not returning the closing </th> or </td> on the table in TestComplete, which is what is breaking the XML conversion.

 

After the </button> tag it should have a </th> tag. I've inspected the element in IE and verified that it includes the </th> tag.

            <th style="width: 7.69%;">Plan Name
                <button uib-tooltip-html="tipPlanName" tooltip-trigger="mouseenter click" tooltip-class="help-swui">?</button>

 

When I run the same thing in Chrome, it returns correctly:

            <th style="width: 7.69231%;">Plan Name
                <button uib-tooltip-html="tipPlanName" tooltip-class="help-swui" tooltip-trigger="mouseenter click">?</button></th>

Does anyone know why I can't get the closing tags to show properly in TestComplete?

  • We managed to find a solution. 

     
    The tags that IE wasn't returning (</td> and </th>) are considered optional tags in HTML5. The utility we used for building our web application was configured to automatically strip optional HTML tags to "minify" the code for performance reasons. So while our source code included those tags, it was being stripped during our build process. We changed our build process to not strip the tags anymore and it's been working since.
     
    Thank you for the help, it's greatly appreciated.
  • jesse2's avatar
    jesse2
    Occasional Contributor

    We managed to find a solution. 

     
    The tags that IE wasn't returning (</td> and </th>) are considered optional tags in HTML5. The utility we used for building our web application was configured to automatically strip optional HTML tags to "minify" the code for performance reasons. So while our source code included those tags, it was being stripped during our build process. We changed our build process to not strip the tags anymore and it's been working since.
     
    Thank you for the help, it's greatly appreciated.
    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      THAT's an interesting piece to know... Thanks for sharing.  We're currently not coding HTML5 applications but, when and if we do, I'll store this bit for later.