1 Replies - 659 Views - Last Post: 01 April 2012 - 03:08 PM Rate Topic: -----

#1 rpp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 30-March 12

Finding text nodes in xml file

Posted 31 March 2012 - 12:59 AM

While parsing xml file using DOM parser if we know the tag names then we can parse the text using getElementsByTagName.But I want to parse the xml file and get the text nodes and edit them but every time the tag names are not knows, Is there any way to edit the xml file if we
don't know the tags?
Is This A Good Question/Topic? 0
  • +

Replies To: Finding text nodes in xml file

#2 DXDenton  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 28-April 10

Re: Finding text nodes in xml file

Posted 01 April 2012 - 03:08 PM

Have you looked at python's SAX API?

http://docs.python.o...xml.sax.handler

Check out the xml.sax.ContentHandler class, which provides (among other things) the startElement method. This method is called when the parser encounters -- you guessed it -- a start tag. The name of the tag is provided in the 'name' parameter. Here is the method signature.

ContentHandler.startElement(name, attrs)


The following is quoted straight from the documentation...

"The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an object of the Attributes interface..."

Take a look and let us know if you have any specific questions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1