7-25<X9>kpg.xml XML 处理

TableOfContents

概览

  1. Para 1:下面两章是关于 Python 中 XML 处理的。如果你已经知道一个 XML 文档的样子,……BR (./) 如果你已经对 XML 文档有了一个大概的了解

  2. Para 3:Being a philosophy major is not required, although if you have ever had the misfortune of being subjected to the writings of Immanuel Kant, you will appreciate the example program a lot more than if you majored in something useful, like computer science. (!) 又一次没有翻译BR (./) 如果你在大学里主修哲学(而不是像计算机科学这样的实用专业),并且曾不幸地被伊曼努尔·康德的著作折磨地够呛,那么你会非常欣赏本章的样例程序。(这当然不意味着你必须修过哲学。)

  3. 例9.3, 标题:Sample output of kgp.py (./) kgp.py 的样例输出

  4. 例9.3下, Para 1, Line -1:但所有内容都 {X} 符合康德的风格。

  5. 例9.4上The interesting thing about this program is that there is nothing Kant-specific about it. 关于这个程序的有趣之处在于没有一点内容是属于康德的。BR (./) 有趣之处在于,这个程序中没有一点内容是属于康德的。

  1. 例9.5, (1):这个语法你之前没有见过。它看上去很像我们所知并且喜欢的 from module import,但是……BR (./) 这个语法你之前没有见过。它看上去很像我们熟知的 from module import,但是……

  2. 例9.6下Python 认为它的意思是:“在 xml 目录中查找 dom 目录,然后在中查找 minidom 模块,……”BR (!) 原文即为斜体BR (./) 在 xml 目录中查找 dom 目录,然后在 这个目录 中查找 minidom 模块

  3. 例9.7, (1):……为了能够引用 minidom 模块中的类(比如 Element),你必须在它们的类名前面加上模块名。BR (./) 引用 minidom 模块中的类(比如 Element),你必须在它们的类名前面加上模块名。

  4. 例9.7, (3)Here you are importing the dom package (a nested package of xml) as a module in and of itself.BR 这里你正在导入 dom 包(xml 的一个嵌套包),并将其作为自己或者内部的 {X} 一个模块。BR (!) in and of 只是对itself 的强调BR

XML 解析

Unicode

搜索元素

访问元素属性

Segue