Answers.Body: <p>The problem is that you have an open UL tag with no close tag. (and an extra  body tag in strange place). Did you paste the code correctly into the Stack Exchange form? </p>
  
  <p>You might want to consider pasting the contents into the calibre editor or sigil editor and beginning from scratch.  Or pasting it into word, removing all formatting except headings and using calibre to convert  from MS Word to epub. Typically calibre generates the tocs from MS word pretty well.   </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-21T05:30:11.410Z
Answers.Text: I don't see any <ul> tags in the above example. There's an <ol> tag which is closed. There's a ul class definition but no tag. Where do you see a tag?
Answers.UserDisplayName: user26732
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-21T11:23:27.790Z
Answers.Text: @user26732 Of course there is a UL tag it starts with `<ul` and has a class attribute `calibre2`. You may want to use [this xhtml validator by w3c.org](http://validator.w3.org/#validate_by_input) to find errors in your source (it indicates four of them), as you don't seem to be too familiar with valid XHTML syntax (and terminology).
Answers.UserDisplayName: Anthon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-21T14:19:51.867Z
Answers.Text: Agreed. I would be much happier with plain old html, but that's not what the tools are throwing at me.
Answers.UserDisplayName: user26732
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-21T05:05:51.187Z
Answers.LastActivityDate: 2017-05-21T05:05:51.187Z
Answers.UserDisplayName: idiotprogrammer
Body: <p>I'm trying to fix a table of contents with the following code and am am getting this error:</p>
  
  <p>"Error at line 20 at column 8: Opening and ending tag mismatch li line 0 and html"</p>
  
  <p>This is confusing because the closing tag for li is </li>, not html. And all the <li> tags are closed. Also, in an ebook, you don't simply have html file where there is a line 20.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no" ?&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"  
  xmlns:epub="http://www.idpf.org/2007/ops" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  
    &lt;head&gt;
      &lt;title&gt;Contents&lt;/title&gt;
      &lt;meta content="text/html; charset=utf-8" http-equiv="Content-  Type"/&gt;
  &lt;link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css"/&gt;
  &lt;link href="../Styles/page_styles.css" rel="stylesheet"    type="text/css"/&gt;
  &lt;/head&gt;
    &lt;body class="calibre"&gt;
      &lt;h1 class="calibre1"&gt;Contents&lt;/h1&gt;
      &lt;ul class="calibre2" id="toc-style"&gt;&lt;li class="calibre3"&gt;
      &lt;body&gt;
      &lt;ol&gt;
      &lt;li&gt;&lt;a class="calibre4" href="../Text/Flow_0_split_000.xhtml"&gt;Foreword/The Art of Correction&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class="calibre4" href="../Text/Flow_0_split_001.xhtml"&gt;The Revelation of Anakum&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class="calibre4" href="../Text/Flow_0_split_002.xhtml"&gt;Justice is Blind&lt;/a&gt;&lt;/li&gt;
      &lt;/ol&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-20T10:39:30.963Z
Comments.Text: What kind of tools are you using to edit your ebook?
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T05:31:19.030Z
Comments.Text: Quark export to ePub, ePub import to Calibre, Calibre convert to ePub (for line spacing and cover), Sigil for ToC tweaking.
Comments.UserDisplayName: user26732
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T13:50:46.747Z
Comments.Text: Calibre can automatically create a ToC for you, instead of having to edit its code manually; as others have pointed out, it is not correctly coded.  Besides that, you might want to try to use just a program (Calibre editor or Sigil) instead of all these passages and conversions.
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T14:22:30.490Z
Comments.Text: I tried. Calibre treated a single footnote as a chapter and didn't recognize the other chapters. Nor would it let me correct or remove an existing ToC that was generated by another program that didn't let me edit the ToC either. That's why I had to break out Sigil in the first place. Now I have a nicely formatted iBooks Author project that apparently cannot be exported to ePub. Arrrgh. And yes, I used their template.
Comments.UserDisplayName: user26732
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T14:39:34.363Z
Comments.Text: If you use <h1> ... <h6> html headers for chapter titles only, and select the option to create entries for main headers, it will work. Having just a footnote recognized as a main entry sounds like your files are not coded with clean and proper html. A program can't interpret your intentions, giving it proper code is a responsibility of yours.
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T16:28:29.110Z
Comments.Text: Using html as an intermediate step isn't a bad idea. But the files were automatically coded by Quark which does not give you the ability to use html tags when exporting. Or even in the text.
Comments.UserDisplayName: user26732
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-21T22:25:38.860Z
Comments.Text: I really can't understand. If you know thay your problems are caused by some of the tools you use, can't you simply discard them and use something else?
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-22T04:05:22.907Z
Comments.Text: You are correct. I suppose I could pay for InDesign. As it is, I'm moving from tools that claim general functionality, but in this specific case they gag. Starting from a Word document to Vellum won't work, because Vellum won't  handle footnotes. Quark can handle footnotes and promises ePub export, but the problems I've outlined are present. iBooks Author creates a .ipa file which can't export to ePub. I haven't tried Pandoc Word>ePub or InDesign or using an intermediate step. I thought fixing the xhtml ToC would be easy, but it's not.
Comments.UserDisplayName: user26732
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-22T05:55:33.490Z
Comments.Text: Like I said, Calibre is perfectly capable of handling this, you don't need to buy  InDesign just for a table of contents...
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-23T04:31:05.803Z
Comments.Text: But it isn't. There are 47 footnotes. The first footnote was listed as if it were a Chapter in the ToC. The Quark-generated ToC remained in the text. The front matter disappeared. One whole Part disappeared. Forcing the ToC didn't help. Und und und. That is why I tried to futz with the xhtml code using Sigil.
Comments.UserDisplayName: user26732
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-23T06:46:49.683Z
Comments.Text: you are not even listening. Calibre CAN properly edit an epub. Use a tool only and not covert between many programs. Use headers properly. If Footnotes are treated as chapters and real chapters are not even recognised, you are not using the correct tags. You really need to learn how to code HTML correctly, you can't blame a program if you don't know how to use it. You already had all the answers, you are on your own now.
Comments.UserDisplayName: Sekhemty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-23T16:28:50.313Z
Comments.Text: You suggested I try to find another tool. I'm trying to find one that works. I've used Calibre on simple files without a problem; for some reason this one throws errors. Coding html is not an issue; coding xml is another story. If an ePub were a single html file beginning with <html> and ending with </html> it would be easy to fix the code. But it's not.
Comments.UserDisplayName: user26732
Tags: <epub>
Title: ToC: Errors Thrown
UserDisplayName: user26732
ThreadText: # ToC: Errors Thrown
  
  (Asked by: username_0 on 2017-05-20)
  
  I'm trying to fix a table of contents with the following code and am am getting this error:
  
  "Error at line 20 at column 8: Opening and ending tag mismatch li line 0 and html"
  
  This is confusing because the closing tag for li is , not html. And all the
  
  - tags are closed. Also, in an ebook, you don't simply have html file where there is a line 20.
  
    Here's the code:
  
    ```
    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <html xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:epub="http://www.idpf.org/2007/ops" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
      <head>
        <title>Contents</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-  Type"/>
    <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css"/>
    <link href="../Styles/page_styles.css" rel="stylesheet"    type="text/css"/>
    </head>
      <body class="calibre">
        <h1 class="calibre1">Contents</h1>
        <ul class="calibre2" id="toc-style"><li class="calibre3">
        <body>
        <ol>
        <li><a class="calibre4" href="../Text/Flow_0_split_000.xhtml">Foreword/The Art of Correction</a></li>
        <li><a class="calibre4" href="../Text/Flow_0_split_001.xhtml">The Revelation of Anakum</a></li>
        <li><a class="calibre4" href="../Text/Flow_0_split_002.xhtml">Justice is Blind</a></li>
        </ol>
  
    </body>
    </html>
  
    ```
  
  **Tags:** epub
  
  > **Comments:**
  > **username_1**: What kind of tools are you using to edit your ebook?  
  > **username_0**: Quark export to ePub, ePub import to Calibre, Calibre convert to ePub (for line spacing and cover), Sigil for ToC tweaking.  
  > **username_1**: Calibre can automatically create a ToC for you, instead of having to edit its code manually; as others have pointed out, it is not correctly coded.  Besides that, you might want to try to use just a program (Calibre editor or Sigil) instead of all these passages and conversions.  
  > **username_0**: I tried. Calibre treated a single footnote as a chapter and didn't recognize the other chapters. Nor would it let me correct or remove an existing ToC that was generated by another program that didn't let me edit the ToC either. That's why I had to break out Sigil in the first place. Now I have a nicely formatted iBooks Author project that apparently cannot be exported to ePub. Arrrgh. And yes, I used their template.  
  > **username_1**: If you use <h1> ... <h6> html headers for chapter titles only, and select the option to create entries for main headers, it will work. Having just a footnote recognized as a main entry sounds like your files are not coded with clean and proper html. A program can't interpret your intentions, giving it proper code is a responsibility of yours.  
  > **username_0**: Using html as an intermediate step isn't a bad idea. But the files were automatically coded by Quark which does not give you the ability to use html tags when exporting. Or even in the text.  
  > **username_1**: I really can't understand. If you know thay your problems are caused by some of the tools you use, can't you simply discard them and use something else?  
  > **username_0**: You are correct. I suppose I could pay for InDesign. As it is, I'm moving from tools that claim general functionality, but in this specific case they gag. Starting from a Word document to Vellum won't work, because Vellum won't  handle footnotes. Quark can handle footnotes and promises ePub export, but the problems I've outlined are present. iBooks Author creates a .ipa file which can't export to ePub. I haven't tried Pandoc Word>ePub or InDesign or using an intermediate step. I thought fixing the xhtml ToC would be easy, but it's not.  
  > **username_1**: Like I said, Calibre is perfectly capable of handling this, you don't need to buy  InDesign just for a table of contents...  
  > **username_0**: But it isn't. There are 47 footnotes. The first footnote was listed as if it were a Chapter in the ToC. The Quark-generated ToC remained in the text. The front matter disappeared. One whole Part disappeared. Forcing the ToC didn't help. Und und und. That is why I tried to futz with the xhtml code using Sigil.  
  > **username_1**: you are not even listening. Calibre CAN properly edit an epub. Use a tool only and not covert between many programs. Use headers properly. If Footnotes are treated as chapters and real chapters are not even recognised, you are not using the correct tags. You really need to learn how to code HTML correctly, you can't blame a program if you don't know how to use it. You already had all the answers, you are on your own now.  
  > **username_0**: You suggested I try to find another tool. I'm trying to find one that works. I've used Calibre on simple files without a problem; for some reason this one throws errors. Coding html is not an issue; coding xml is another story. If an ePub were a single html file beginning with <html> and ending with </html> it would be easy to fix the code. But it's not.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-05-21. Score: 1 | Accepted answer
  
  The problem is that you have an open UL tag with no close tag. (and an extra body tag in strange place). Did you paste the code correctly into the Stack Exchange form?
  
  You might want to consider pasting the contents into the calibre editor or sigil editor and beginning from scratch. Or pasting it into word, removing all formatting except headings and using calibre to convert from MS Word to epub. Typically calibre generates the tocs from MS word pretty well.
  
  > **Comments:**
  > **username_0**: I don't see any <ul> tags in the above example. There's an <ol> tag which is closed. There's a ul class definition but no tag. Where do you see a tag?  
  > **username_3**: @username_0 Of course there is a UL tag it starts with `<ul` and has a class attribute `calibre2`. You may want to use [this xhtml validator by w3c.org](http://validator.w3.org/#validate_by_input) to find errors in your source (it indicates four of them), as you don't seem to be too familiar with valid XHTML syntax (and terminology).  
  > **username_0**: Agreed. I would be much happier with plain old html, but that's not what the tools are throwing at me.  
  
  ---
  
  