InitializeXMLParser
InitializeXMLParser[root,"file"]
creates an XMLParser object that has a list of entities corresponding to the contents of "file" and can be used on XML documents that have a root element root.
更多信息和选项
范例
基本范例
参见
技术笔记
相关指南
XML`
XML`
InitializeXMLParser
InitializeXMLParser[root,"file"]
creates an XMLParser object that has a list of entities corresponding to the contents of "file" and can be used on XML documents that have a root element root.
更多信息和选项
- To use InitializeXMLParser, you first need to load the XML Package using Needs["XML`"].
- InitializeXMLParser can be used to preload a DTD. If many documents with the same DTD are to be loaded repeatedly, a pre-initialized parser can speed up processing time.
范例
基本范例 (1)
Needs["XML`"]Initialize a MathML parser (with a preloaded DTD):
mathMLParser = InitializeXMLParser["math", "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd"]The pre-initialized MathML parser is much faster than reloading the DTD:
Timing[XMLGetString["<!DOCTYPE math SYSTEM 'http://www.w3.org/TR/MathML2/dtd/mathml2.dtd'><math><mn>1</mn></math>", mathMLParser];]Timing[XMLGetString["<!DOCTYPE math SYSTEM 'http://www.w3.org/TR/MathML2/dtd/mathml2.dtd'><math><mn>1</mn></math>"];]For validation, a DOCTYPE declaration does not need to be present when using a pre-initialized parser:
XMLGetString["<math><mn>1</mn></math>", mathMLParser, "ValidateAgainstDTD" -> True]ReleaseXMLParser frees up resources when the parser is done:
ReleaseXMLParser[mathMLParser]