实例介绍
SgmlReader是由Chris Lovett编写的一个多功能C# .NET库,用于使用XmlReader API解析HTML/SGML文件。此外,还提供了一个命令行实用程序,可以输出格式良好的XML结果。MindTouch对SgmlReader库进行了广泛使用,并在过去几年中对其进行了许多改进。
SgmlReaderDll API
SgmlReader实现了XmlReader API。因此,您真正需要知道的只是如何构造它。SgmlReader有一个默认构造函数,然后您需要设置一些属性。要加载DTD,必须指定DocType="HTML",或者必须提供SystemLiteral。要指定SGML文档,必须提供InputStream或Href。其他所有内容都是可选的。然后,您可以像使用任何其他XmlReader类一样从这个读取器读取。
示例使用:
XmlDocument FromHtml(TextReader reader) {
// setup SgmlReader
Sgml.SgmlReader sgmlReader = new Sgml.SgmlReader();
sgmlReader.DocType = "HTML";
sgmlReader.WhitespaceHandling = WhitespaceHandling.All;
sgmlReader.CaseFolding = Sgml.CaseFolding.ToLower;
sgmlReader.InputStream = reader;
// create document
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.XmlResolver = null;
doc.Load(sgmlReader);
return doc;
}
SgmlReader属性介绍和命令行工具使用说明等详细信息,展示了如何灵活运用SgmlReader处理和转换HTML/SGML数据至XML格式,为开发人员提供了强大的解析工具。
【实例截图】
【核心代码】
文件清单
└── SGMLReader-fe11cefdc23d66f0bc6f5c8e45a7b17b171f62ab
├── build.ps1
├── default.ps1
├── Demo.aspx
├── license.txt
├── packages
│ ├── log4net.1.2.10
│ │ ├── lib
│ │ │ ├── 1.0
│ │ │ │ ├── log4net.dll
│ │ │ │ └── log4net.xml
│ │ │ ├── 1.1
│ │ │ │ ├── log4net.dll
│ │ │ │ └── log4net.xml
│ │ │ └── 2.0
│ │ │ ├── log4net.dll
│ │ │ └── log4net.xml
│ │ └── log4net.1.2.10.nupkg
│ ├── NUnit.2.5.10.11092
│ │ ├── fit-license.txt
│ │ ├── lib
│ │ │ ├── nunit.framework.dll
│ │ │ ├── nunit.framework.xml
│ │ │ ├── nunit.mocks.dll
│ │ │ └── pnunit.framework.dll
│ │ ├── license.txt
│ │ ├── Logo.ico
│ │ ├── NUnit.2.5.10.11092.nupkg
│ │ ├── NUnitFitTests.html
│ │ └── tools
│ │ ├── agent.conf
│ │ ├── agent.log.conf
│ │ ├── launcher.log.conf
│ │ ├── lib
│ │ │ ├── Failure.png
│ │ │ ├── fit.dll
│ │ │ ├── Ignored.png
│ │ │ ├── Inconclusive.png
│ │ │ ├── log4net.dll
│ │ │ ├── nunit-console-runner.dll
│ │ │ ├── nunit.core.dll
│ │ │ ├── nunit.core.interfaces.dll
│ │ │ ├── nunit.fixtures.dll
│ │ │ ├── nunit-gui-runner.dll
│ │ │ ├── nunit.uiexception.dll
│ │ │ ├── nunit.uikit.dll
│ │ │ ├── nunit.util.dll
│ │ │ ├── Skipped.png
│ │ │ └── Success.png
│ │ ├── nunit-agent.exe
│ │ ├── nunit-agent.exe.config
│ │ ├── nunit-agent-x86.exe
│ │ ├── nunit-agent-x86.exe.config
│ │ ├── nunit-console.exe
│ │ ├── nunit-console.exe.config
│ │ ├── nunit-console-x86.exe
│ │ ├── nunit-console-x86.exe.config
│ │ ├── nunit.exe
│ │ ├── nunit.exe.config
│ │ ├── nunit.framework.dll
│ │ ├── NUnitTests.config
│ │ ├── NUnitTests.nunit
│ │ ├── NUnitTests.VisualState.xml
│ │ ├── nunit-x86.exe
│ │ ├── nunit-x86.exe.config
│ │ ├── pnunit-agent.exe
│ │ ├── pnunit-agent.exe.config
│ │ ├── pnunit.framework.dll
│ │ ├── pnunit-launcher.exe
│ │ ├── pnunit-launcher.exe.config
│ │ ├── pnunit.tests.dll
│ │ ├── runFile.exe
│ │ ├── runFile.exe.config
│ │ ├── runpnunit.bat
│ │ ├── test.conf
│ │ └── TestResult.xml
│ └── repositories.config
├── ReadMe.md
├── SgmlReader
│ ├── App.ico
│ ├── AssemblyInfo.cs
│ ├── Html.dtd
│ ├── htmllat1.ent
│ ├── HTMLspecial.ent
│ ├── HTMLsymbol.ent
│ ├── Main.cs
│ └── SgmlReader.csproj
├── sgmlreaderdll
│ ├── AssemblyInfo.cs
│ ├── SgmlParser.cs
│ ├── SgmlReader.cs
│ ├── SgmlReaderDll.csproj
│ └── sgmlreader.snk
├── SGMLReader.nuspec
├── SgmlReader.sln
├── SGMLTests
│ ├── AssemblyInfo.cs
│ ├── LoggingXmlReader.cs
│ ├── ofx160.dtd
│ ├── packages.config
│ ├── Resources
│ │ ├── 01.test
│ │ ├── 02.test
│ │ ├── 03.test
│ │ ├── 04.test
│ │ ├── 05.test
│ │ ├── 06.test
│ │ ├── 07.test
│ │ ├── 08.test
│ │ ├── 09.test
│ │ ├── 10.test
│ │ ├── 11.test
│ │ ├── 12.test
│ │ ├── 13.test
│ │ ├── 14.test
│ │ ├── 15.test
│ │ ├── 16.test
│ │ ├── 17.test
│ │ ├── 18.test
│ │ ├── 19.test
│ │ ├── 20.test
│ │ ├── 21.test
│ │ ├── 22.test
│ │ ├── 23.test
│ │ ├── 24.test
│ │ ├── 25.test
│ │ ├── 26.test
│ │ ├── 27.test
│ │ ├── 28.test
│ │ ├── 29.test
│ │ ├── 30.test
│ │ ├── 31.test
│ │ ├── 32.test
│ │ ├── 33.test
│ │ ├── 34.test
│ │ ├── 35.test
│ │ ├── 36.test
│ │ ├── 37.test
│ │ ├── 38.test
│ │ ├── 39.test
│ │ ├── 40.test
│ │ ├── 41.test
│ │ ├── 42.test
│ │ ├── 43.test
│ │ ├── 44.test
│ │ ├── 45.test
│ │ ├── 46.test
│ │ ├── 47.test
│ │ ├── 48.test
│ │ ├── 49.test
│ │ ├── 50.test
│ │ ├── 51.test
│ │ ├── 52.test
│ │ ├── 53.test
│ │ ├── 54.test
│ │ ├── 55.test
│ │ ├── 56.test
│ │ ├── 57.test
│ │ ├── 58.test
│ │ ├── 59.test
│ │ ├── 60.test
│ │ ├── 61.test
│ │ └── original.test
│ ├── SGMLTests.csproj
│ ├── Tests.cs
│ └── Tests-Logic.cs
└── tools
├── nuget
│ └── NuGet.exe
└── psake
├── psake.ps1
└── psake.psm1
18 directories, 154 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论