Chilkat Software Chilkat Software Chilkat Software
Chilkat Software Chilkat Software

  

  

  

  

  

 

HTML to XML Conversion Sample #2

Goto Sample #1

Goto Sample #3

Goto Sample #4

This is the 2nd of several examples describing the details of how the Chilkat HTML-to-XML library converts HTML into well-formed XML.

Here is another HTML sample:

<html>
<head>
<title>This is a test</title>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<ul>
<li>A quibus tantum dissentio
<li>Sophocles vel optime scripserit Electram
<li>tamen male conversam Atilii mihi legendam putem
<li>de quo Lucilius: 'ferreum scriptorem', verum, opinor, scriptorem tamen
</ul> 
</body>
</html>

The XML output is shown below.

  • Unclosed tags, such as <li>, are automatically closed.
  • All text content is placed under <text> nodes.
<?xml version="1.0" encoding="windows-1252" ?>

<root>
    <html>
        <head>
            <title>
                <text>This is a test</text>
            </title>
            <meta http-equiv="Content-Language" content="en-us"></meta>
            <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
        </head>
        <body>
            <ul>
                <li>
                    <text>A quibus tantum dissentio
                    </text>
                </li>
                <li>
                    <text>Sophocles vel optime scripserit Electram
                    </text>
                </li>
                <li>
                    <text>tamen male conversam Atilii mihi legendam putem
                    </text>
                </li>
                <li>
                    <text>de quo Lucilius: &apos;ferreum scriptorem&apos;, verum, opinor, scriptorem tamen
                    </text>
                </li>
            </ul>
        </body>
    </html>
</root>

(The Chilkat HTML-to-XML API is offered across many programming languages: Ruby, Perl, Python, Java, C#, VB.NET, etc.)


Privacy Statement. Copyright 2000-2016 Chilkat Software, Inc. All rights reserved.

(Regarding the usage of the Android logo) Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Send feedback to support@chilkatsoft.com


Software components and libraries for Linux, MAC OS X, iOS, Android™, Solaris, RHEL/CentOS, FreeBSD, MinGW
Azure, Windows 10, Windows 8, Windows Server 2012, Windows 7, Vista, XP, 2003 Server, 2008 Server, etc.