MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/409899_xmlreader2/recipe-409899.py:90–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89
90def test():
91 dic = readConfig("sample.xml")
92
93 print dic["Config"]["Name"]
94 print
95 print "Item Type:", dic["Config"]["Items"]["Type"]
96 for item in dic["Config"]["Items"]["Item"]:
97 print "Item's Name:", item["Name"]
98 print "Item's Value:", item["Value"]
99
100 """
101 ==================================================
102 sample.xml:
103 ==================================================
104 <?xml version="1.0" encoding="UTF-8"?>
105
106 <Config>
107 <Name>My Config File</Name>
108
109 <Items>
110 <Type>Item type</Type>
111 <Item>
112 <Name>First Item</Name>
113 <Value>Value 1</Value>
114 </Item>
115 <Item>
116 <Name>Second Item</Name>
117 <Value>Value 2</Value>
118 </Item>
119 </Items>
120
121 </Config>
122
123
124 ==================================================
125 output:
126 ==================================================
127 [u'My Config File']
128
129 Item Type: Item type
130 Item&#x27;s Name: First Item
131 Item&#x27;s Value: Value 1
132 Item&#x27;s Name: Second Item
133 Item&#x27;s Value: Value 2
134 """
135

Callers

nothing calls this directly

Calls 1

readConfigFunction · 0.70

Tested by

no test coverage detected