Answer the question
In order to leave comments, you need to log in
How to get an element from the DOM tree?
<page>
<domains>
<domain>
<emails>
<action-status/>
<email>
<name>[email protected]</name>
</email>
<email>
<name>[email protected]</name>
</email>
<email>
<name>[email protected]</name>
</email>
<email>
<name>[email protected]</name>
</email>
<email>
<name>[email protected]</name>
</email>
...
DOMTree = xml.dom.minidom.parse(urllib.urlopen(path))
collection = DOMTree.documentElement
movies = collection.getElementsByTagName("email")
data = []
for movie in movies:
type = movie.getElementsByTagName('name')[0]
data.append(type.childNodes[0].data)
return HttpResponse(data)
Answer the question
In order to leave comments, you need to log in
But outputs everything in a line.
var headings = document.evaluate("*//email/name", document, null, XPathResult.ANY_TYPE, null);
var thisHeading = headings.iterateNext();
var alertText = "Level 2 headings in this document are:\n";
while (thisHeading) {
alertText += thisHeading.textContent + "\n";
thisHeading = headings.iterateNext();
}
alert(alertText); // Alerts the text of all h2 elements
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question