why do I receive an empty document [#document: null] when I read a xml file with xmlread?
102 ビュー (過去 30 日間)
Robert Snoeberger 2015 年 12 月 19 日
編集済み: Robert Snoeberger 2015 年 12 月 19 日
I'm not sure why you think that you received an empty document.
The display that you are seeing, [#document: null], consists of two parts. The first part is #document, which is the node name. When you parse XML with xmlread, you always receive a #document node as the top-level node.
>> dom = xmlread('example.xml')
The second part is null, which is the value of the node. null is used to indicate that the node doesn't have a value.
A #text node usually has a value. In your example, the text node under the first cell element has a value of '65'.
>> cells = dom.getElementsByTagName('cell');
>> cell = cells.item(0)
>> text = cell.item(0)