I want to convert an HTML file into an XML document using php. I've googled and been through some of *'s questions, but couldn't find any solution.
我想使用php将HTML文件转换为XML文档。我用谷歌搜索并经历了一些*的问题,但找不到任何解决方案。
This is my html code and i want to convert it into XML doc.
这是我的HTML代码,我想将其转换为XML文档。
<html>
<body>
<ul>
<li>Section 1</li>
<li>Section 2
<ul>
<li>Section 2.1</li>
<li>Section 2.2</li>
</ul>
</li>
<li>Section 3</li>
</ul>
</body>
</html>
and i want it into
我想要它
<root>
<part>
<number>Section 1</number>
<number>Section 2</number>
<child_number>Section 2.1</child_number>
<child_number>Section 2.2</child_number>
<number>Section 3</number>
</part>
</root>
if there is any technique for converting this html file into XML using php, then please help me. Any help would be thankful.
如果有任何技术使用PHP将此html文件转换为XML,那么请帮助我。任何帮助都会感激不尽。
1 个解决方案
#1
0
It looks like someone was able to do something similar to what you are looking for using tidy. Converting HTML to XML. If this is not an option then you may be left to writing a set of code that can handle your html files and export them to xml.
看起来有人能够做一些类似于你正在寻找的东西。将HTML转换为XML。如果这不是一个选项,那么你可能需要编写一组代码来处理你的html文件并将它们导出到xml。
#1
0
It looks like someone was able to do something similar to what you are looking for using tidy. Converting HTML to XML. If this is not an option then you may be left to writing a set of code that can handle your html files and export them to xml.
看起来有人能够做一些类似于你正在寻找的东西。将HTML转换为XML。如果这不是一个选项,那么你可能需要编写一组代码来处理你的html文件并将它们导出到xml。