xml - edit the END TAG ONLY of an element using minidom in python? -


i having few issues python's minidom, , wondering if guys me out!

i trying convert xml data wrong format format read our system. have been working on sort of proof-of-concept , figured out except last little issue!

here's have far.

while y < length:      tag = doc_root.getelementsbytagname("p")[y].toxml()     xmldata = tag.replace(' region="bottom"','')     z = z + 1     xmldata= xmldata.replace(' xml:id="p%d"'%z,'')     xmldata = xmldata.replace('<p','p')     xmldata = xmldata.replace('/p>','p')     print xmldata      #div.appendchild(doc_root.getelementsbytagname("p")[x])     print xmldata     adddata = doc.createelement(xmldata)     div.appendchild(adddata)     y = y+1 

now works great, except when printed xml this

<p begin="00:00:02.470" end="00:00:05.388">organizational communication and<br/>deaf employees<p/> 

when need this

<p begin="00:00:02.470" end="00:00:05.388">organizational communication and<br/>deaf employees</p> 

i think understand issue is, appending child string , because of element automatically makes <> , </>, right? how prevent last </> happening?

edit: mzjn has asked example of xml data.

this xml (with sensitive parts removed)

<tt xml:lang="mi" ***********> <head>     <metadata>         <ttm:title>*********</ttm:title>         <ttm:agent type="person" xml:id="author_1">             <ttm:name type="full">no author</ttm:name>         </ttm:agent>     </metadata>     <styling>         <style tts:color="white" tts:fontfamily="arial" tts:fontsize="24" tts:fontstyle="normal" tts:fontweight="bold" tts:textalign="center" xml:id="s1"/>     </styling>     <layout>         <region tts:displayalign="before" tts:extent="80% 80%" tts:origin="10% 10%" xml:id="top"/>         <region tts:displayalign="center" tts:extent="80% 80%" tts:origin="10% 10%" xml:id="center"/>         <region tts:displayalign="after" tts:extent="80% 80%" tts:origin="10% 10%" xml:id="bottom"/>     </layout> </head> <body>     <div style="s1" xml:id="d1" xml:lang="mi">         <p begin="00:00:02.470" end="00:00:05.388" region="bottom" xml:id="p1">organizational communication and<br/>deaf employees</p> continues each <p> tag until </div> </body> , </tt> 

i need change this:

    <?xml version="1.0" ?> <tt xmlns=****** xml:lang="en">     <body>         <div xml:lang="en" style="1">             <p begin="00:00:02.470" end="00:00:05.388">organizational communication and<br/>deaf employees</p> 


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -