@@ -124,6 +124,38 @@ def test_xmliter_iterate_namespace(self):
124124 node = next (namespace_iter )
125125 self .assertEqual (node .xpath ('text()' ).extract (), ['http://www.mydummycompany.com/images/item2.jpg' ])
126126
127+ def test_xmliter_namespaces_prefix (self ):
128+ body = """\
129+ <?xml version="1.0" encoding="UTF-8"?>
130+ <root>
131+ <h:table xmlns:h="http://www.w3.org/TR/html4/">
132+ <h:tr>
133+ <h:td>Apples</h:td>
134+ <h:td>Bananas</h:td>
135+ </h:tr>
136+ </h:table>
137+
138+ <f:table xmlns:f="http://www.w3schools.com/furniture">
139+ <f:name>African Coffee Table</f:name>
140+ <f:width>80</f:width>
141+ <f:length>120</f:length>
142+ </f:table>
143+
144+ </root>
145+ """
146+ response = XmlResponse (url = 'http://mydummycompany.com' , body = body )
147+ my_iter = self .xmliter (response , 'table' , 'http://www.w3.org/TR/html4/' , 'h' )
148+
149+ node = next (my_iter )
150+ self .assertEqual (len (node .xpath ('h:tr/h:td' ).extract ()), 2 )
151+ self .assertEqual (node .xpath ('h:tr/h:td[1]/text()' ).extract (), ['Apples' ])
152+ self .assertEqual (node .xpath ('h:tr/h:td[2]/text()' ).extract (), ['Bananas' ])
153+
154+ my_iter = self .xmliter (response , 'table' , 'http://www.w3schools.com/furniture' , 'f' )
155+
156+ node = next (my_iter )
157+ self .assertEqual (node .xpath ('f:name/text()' ).extract (), ['African Coffee Table' ])
158+
127159
128160class UtilsCsvTestCase (unittest .TestCase ):
129161 sample_feeds_dir = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'sample_data' , 'feeds' )
0 commit comments