Extremely frustrating problem, have wasted hours on this and can't find a solution.
I'm using dom/minidom through Python and can't use any other external Python modules.
Basically, we have the following example XML:
<a id="1"> <b> <c>1</c> <c>2</c> <c>3</c> </b> </a> <a id="2"> <b> <c>1</c> <c>2</c> <c>3</c> </b> </a> <a id="3"> <b> <c>1</c> <c>2</c> <c>3</c> </b> </a>
What I'm attempting to do is only pull data from the first c of every b element which is nested inside a. All I'm able to do at the moment is pull all data contained in all available c's.
sText = dom.getElementsByTagName('a')
for node in sText:
sTextList = node.getElementsByTagName('c')
for i in sTextList:
dataText = i.firstChild.data
print dataText.encode('utf-8'), "<br />"
Currently, all this achieves is:
1 2 3 1 2 3 1 2 3
Is there a way I just pull the FIRST c (as in, only "1") instead of all of them with the above code? This is driving me insane...
Thanks in advance!






