-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Python Deep Learning - Third Edition ($39.99 Value) — Free, in exchange for your Email
By News Staff,
- ebook offer
- sponsored
- (and 2 more)
- 0 replies
- 1 view
-
Python Real-World Projects ($36.99 Value) FREE eBook download offer ends Jan 2
By News Staff,
- ebook offer
- sponsored
- (and 2 more)
- 0 replies
- 2 views
-
Python for Security and Networking - Third Edition ($39.99 Value) FREE download
By News Staff,
- ebook offer
- sponsored
- (and 2 more)
- 0 replies
- 2 views
-
Python Machine Learning ($24.00 Value) eBook FREE for a Limited Time
By News Staff,
- ebook offer
- sponsored
- (and 3 more)
- 0 replies
- 2 views
-
Microsoft launches the experimental Python Editor from Excel Labs
By John Callaham,
- microsoft
- microsoft excel
- (and 4 more)
- 2 replies
- 2 views
-
Question
Snowstorm
Hey guys,
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:
What I'm attempting to do is only pull data from the first [i]c[/i] of every [i]b[/i] element which is nested inside [i]a[/i]. All I'm able to do at the moment is pull all data contained in all available [i]c[/i]'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 />"
[/CODE]
Currently, all this achieves is:
1
2
3
1
2
3
1
2
3
[/CODE]
Is there a way I just pull the FIRST [i]c[/i] (as in, only "1") instead of all of them with the above code? This is driving me insane...
Thanks in advance!
Link to comment
Share on other sites
5 answers to this question
Recommended Posts