简体   繁体   English

分配给innerHTML时,HTML标记会更改

[英]HTML tags get changed when assigning to innerHTML

I have an XML and im transforming it to HTML using XSL. 我有一个XML,并使用XSL将其即时转换为HTML。 My transformation is successful and i am geting the resultant string like below :- ` 我的转换成功,并且我得到了如下所示的结果字符串:

<TABLE xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xslscript="http://mycompany.com/mynamespace" border="0" width="100%">
   <TR align="center">
      <TD>
         <TABLE border="0" cellspacing="0" cellpadding="0" width="100%">
            <FORM action="jhk" method="get" id="frmMain" name="frmMain">
               <TR>
                  <TD class="tableBg">
                     <TABLE border="0" cellspacing="1" cellpadding="3" width="100%">
                        <TR class="mainListRow">
                           <TD colspan="7">
                              <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
                                 <TR>
                                    <TD class="ListTableTitle" width="12%" nowrap="nowrap">Select Value                    </TD>
                                 </TR>
                              </TABLE>
                           </TD>
                        </TR>
                        <TR width="100%">
                           <TD valign="top" width="100%">
                              <DIV id="listing" width="100%">
                                 <input type="hidden" id="keyField" value="partnerCd"/>
                                 <TABLE STYLE="background-color:white" id="tblList" border="0" bordercolor="#0099CC" cellspacing="0" width="100%">
                                    </THEAD>
                                    <tr>
                                       <TD align="center" width="8px" height="10px"/>
                                       <TD colspan="1">
                                          <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                             <tr>
                                                <td><input type="text" class="text" name="searchFields" value=""/></td>
                                             </tr>
                                          </table>
                                       </TD>
                                       <TD colspan="1">
                                          <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                             <tr>
                                                <td/>
                                                <td align="right"><input type="button" class="buttonsNewCancelDeleteClose" id="buttonsSearchId" name="buttonsSearch" value="Search" onclick="searchPaginated()"/></td>
                                             </tr>
                                          </table>
                                       </TD>
                                    </tr>
                                 </TABLE>
                              </DIV>
                           </TD>
                        </TR>
                     </TABLE>
                  </TD>
               </TR>
               <TR>
                  <td>
                     <table cellpadding="0" cellspacing="0" width="100%">
                        <tr class="tableFooter">
                           <td class="tableFooter" align="left" width="10%"/>
                           <TD class="tableFooter" id="tableFooter" width="90%" align="right"/>
                        </tr>
                     </table>
                  </td>
               </TR>
            </FORM>
         </TABLE>
      </TD>
   </TR>
</TABLE>

` `

then i am assigning it to the innerHTML of Document.. but the form tag is closing in the same line after assignment. 然后我将其分配给Document。的innerHTML。.但是赋值后,表单标签在同一行中关闭。 like below 像下面

<FORM action="jhk" method="get" id="frmMain" name="frmMain"></FORM>

Not able to understand why the tags are rallying.Can anyone please help .I am not able to find any missmatch. 无法理解标签为什么会聚集。有人可以提供帮助。我找不到任何不匹配的内容。

thanks 谢谢

A <form> can not be inside a <table> . <form>不能在<table>

Either place it around the <table> or in a <td> 将其放在<table>周围或<td>

In addition, you have a stray </THEAD> tag on line 24 of your sample HTML. 此外,示例HTML的第24行上还有一个</THEAD>标记。 This stray tag results in invalid markup, which could be causing the symptoms you're seeing. 此流浪标签会导致无效的标记,这可能会导致您看到的症状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM