解析 XML 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5140743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does parsing XML mean?
提问by dwyane
Can someone please explain to me what parsing XML means? And what does an XML parser do in general?
有人可以向我解释解析 XML 的含义吗?XML 解析器通常做什么?
回答by Manrico Corazzi
It means "reading" the XML file/string and getting its content according to the structure, usually to use them in a program.
它的意思是“读取”XML 文件/字符串并根据结构获取其内容,通常是在程序中使用它们。
For example if you have this XML fragment:
例如,如果您有这个 XML 片段:
<root>
<node1>value1</node1>
<node2>value2</node2>
</root>
you may want to use these values in a data structure:
您可能希望在数据结构中使用这些值:
ClassRoot:
node1: string
node2: string
so that, in the end:
所以,最后:
Object goofy = ClassRoot.new
parse(xml, goofy)
puts(goofy)
yelds something like:
发出类似的声音:
goofy[node1='value1'; node2='value2']
There are many ways of doing so, like DOM or SAX. You might want to investigate XSLTand xpathas well, according to your needs.
回答by Naveed
An XML parser is the piece of software that reads XML files and makes the information from those files available to applications and programming languages, usually through a known interface like the DOM
XML 解析器是一种软件,它读取 XML 文件并将这些文件中的信息提供给应用程序和编程语言,通常通过一个已知的接口,如 DOM
回答by Sergey
Usually some information is stored in xml documents. In order to use this information in your program you have to parse it - read line by line or node by node and fetch pieces of information.
通常一些信息存储在xml文件中。为了在您的程序中使用此信息,您必须对其进行解析 - 逐行或逐节点读取并获取信息片段。
回答by Rudrik
An XML parser converts an XML document into an XML DOM object - which can then be manipulated with a JavaScript.
XML 解析器将 XML 文档转换为 XML DOM 对象 - 然后可以使用 JavaScript 对其进行操作。
回答by Greg
XML: Extensible Markup Language is a set of rules for encoding documents electronically. It is defined in the produced by the W3C and several other related specifications; all are fee-free open standards.
XML:可扩展标记语言是一组用于对文档进行电子编码的规则。它在 W3C 和其他几个相关规范中定义;都是免费的开放标准。
Parser: a computer program that divides code up into functional components; "compilers must parse source code in order to translate it into object code"
解析器:将代码划分为功能组件的计算机程序;“编译器必须解析源代码才能将其翻译成目标代码”

