Timeline for answer to How can I parse XML and get instances of a particular node attribute? by Ryan Christensen
Current License: CC BY-SA 4.0
Post Revisions
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 25, 2022 at 11:30 | comment | added | spoonsearch |
To get the value of "item1" you do this- element.firstChild.nodeValue
|
|
| Apr 9, 2022 at 10:52 | history | edited | Mateen Ulhaq | CC BY-SA 4.0 |
Clarify print statement outputs and rename variables to more conventional ones.
|
| Apr 9, 2022 at 10:41 | history | edited | Mateen Ulhaq | CC BY-SA 4.0 |
Syntax highlighting.
|
| Jun 11, 2021 at 11:17 | comment | added | baponkar |
Use for s in itemlist: print(s.childNodes[0].data) to get data from <item> This is a item </item>`
|
|
| Sep 21, 2020 at 2:31 | comment | added | MiffTheFox |
Big recommendation for minidom. It's perfect for developers coming from other languages who know DOM through things like SimpleXML, System.Xml, or even just HTML DOM.
|
|
| Dec 12, 2019 at 23:18 | history | edited | the Tin Man | CC BY-SA 4.0 |
edited for readability
|
| Nov 20, 2017 at 14:49 | comment | added | jlh |
The doc of this library begins with a very worrisome text: Warning The xml.dom.minidom module is not secure against maliciously constructed data. If you need to parse untrusted or unauthenticated data see XML vulnerabilities.
|
|
| Apr 5, 2017 at 5:00 | comment | added | Alex Borsody |
The syntax won't work here you need to remove parenthesis for s in itemlist: print(s.attributes['name'].value)
|
|
| Feb 23, 2015 at 10:22 | history | edited | Martin Thoma | CC BY-SA 3.0 |
Python 3 compatibility; PEP8 compatibility; added link to minidom documentation
|
| Jan 14, 2014 at 21:05 | comment | added | amphibient | please see stackoverflow.com/questions/21124018/… | |
| Jan 14, 2014 at 20:49 | comment | added | amphibient |
I am also confused why it finds item straight from the top level of the document? wouldn't it be cleaner if you supplied it the path (data->items)? because, what if you also had data->secondSetOfItems that also had nodes named item and you wanted to list only one of the two sets of item?
|
|
| Jan 14, 2014 at 20:43 | comment | added | amphibient |
where is the documentation for minidom ? I only found this but that doesn't do: docs.python.org/2/library/xml.dom.minidom.html
|
|
| S Aug 2, 2013 at 12:01 | history | suggested | rahmu | CC BY-SA 3.0 |
formatting
|
| Aug 2, 2013 at 11:59 | review | Suggested edits | |||
| S Aug 2, 2013 at 12:01 | |||||
| Feb 13, 2013 at 14:03 | comment | added | swmcdonnell | How do you get the value of "item1"? For example: <item name="item1">Value1</item> | |
| Dec 16, 2009 at 5:30 | history | answered | Ryan Christensen | CC BY-SA 2.5 |