Skip to Content
可编程网络自动化
book

可编程网络自动化

by Jason Edelman, Scott S. Lowe, Matt Oswalt
January 2023
Intermediate to advanced
458 pages
14h 16m
Chinese
Posts & Telecom Press
Content preview from 可编程网络自动化
126
5
<device>
元素),嵌套在一个覆盖范围更广的
<devices>
标签内。
另外,我们还注意到每个子元素都包含数据。根元素包含
XML
子元素
,子元素包含文本
数据。回想一下数据类型部分,这些可以使用
Python
程序中的字符串值来描述。
XML
元素也具有属性。
<device
type="datacenter-switch"
/>
部分信息可能会有一些与之关联的元数据,使用子元素未必合适,这时就可以使用属性。
XML
规范也实现了名称空间系统
,该系统能避免出现元素命名冲突。在创建
XML
文档
时,开发人员可以任意选用名称。当软件使用
XML
,可能会为两个
XML
元素指定同
样的名称,但元素的内容和用途各不相同。
例如,
XML
文档可以实现下列元素。
<device>
Palm Pilot
</device>
这个例子中使用了元素名称
<device>
,但其用途显然不是为了描述网络设备,其意义与之
前例子中的交换机定义完全不同。
通过
xmlns
命名在
XML
文档中定义并利用前缀,名称空间可以帮助解决这一问题。
<root>
<e:device
xmlns:c="http://exampleurl/enduserdevices"
>
Palm Pilot
</e:device>
<n:device
xmlns:m="http://exampleurl/networkdevices"
>
<n:vendor>
Cisco
</n:vendor>
<n:model>
Nexus 7700
</n:model>
<n:osver> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python和NLTK实现自然语言处理

Python和NLTK实现自然语言处理

Posts & Telecom Press, Nitin Hardeniya
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
弱监督学习实用指南

弱监督学习实用指南

Wee Hyong Tok, Amit Bahree, Senja Filipi
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham

Publisher Resources

ISBN: 9787115606181