473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

DOM method to go to the tag with particular attribute value ..with example

DOM method to go to the tag with particular attribute value ..with example
Jul 12 '10 #1
1 1021
bvdet
2,851 Expert Mod 2GB
Here's a simple example:
Expand|Select|Wrap|Line Numbers
  1. from xml.dom.minidom import parseString
  2. xml_str = """<?xml version="1.0" ?>
  3. <ROOT>
  4. <pitch>The data is in between opening and closing tags.</pitch>
  5. <pitch>More data</pitch>
  6. </ROOT>"""
  7.  
  8. xmlDoc = parseString(xml_str)
  9.  
  10. elemList = xmlDoc.getElementsByTagName('pitch')
  11.  
elemList is a list of the elements with the tag "pitch". To get the text from the child element:
Expand|Select|Wrap|Line Numbers
  1. for elem in elemList:
  2.     for child in elem.childNodes:
  3.         print child.nodeValue
Jul 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jason Bell | last post by:
Give the following custom attribute: public class WidgetEventAttribute : System.Attribute { protected Cegui.EventHandler mEventHandler = null; public WidgetEventAttribute( string...
2
by: sosh | last post by:
Hi, Sorry for the simple question, but could anyone tell me the best way to test for the existance of an element with a particular attribute value (id) ? Thanks
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
1
by: Carlo Folini | last post by:
Hi, I have the following xsl: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template...
2
by: eggie5 | last post by:
This is a snippet from my page: <form name="form1" method="post" action="Default.aspx?id=365272" id="form1" enctype="multipart/form-data"> I need some javascript that can check if the id query...
5
by: Oleg.Ogurok | last post by:
Hi there, I need to encode the value of an XML attribute, e.g. string myXml = "<element myAttr=\"" + encodeURIComponent("my \"value") + "\"" ...."; Is there an equivalent of...
0
by: kelvin273 | last post by:
Hi all, i'm new in this community (and in .NET programming) and i've a problem with xpathnavigator. The idea is to have an xml document with attribute editable by windows form. I write this...
1
by: john20 | last post by:
Hi All, I have an XMl structure and i am creating XML Schema document for validating xml document. What i want that for a particular element it should not allow same attribute name. for...
5
darksteel21
by: darksteel21 | last post by:
I have an xml file : <?xml version="1.0"?> <profile id="4" sap="7778"> <name="Mark"></name> <name="Mark"></name> <name="Mark"></name> </profile> I wan to modify the "id" attribute...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.