Skip to main content
added 1 character in body
Source Link
Akhitha
  • 43
  • 1
  • 2
  • 6

I have to delete particular tags from an xml file. Sample xml below.


 
       <data:abc><data>
          <tag:action tag:language="name"/>
        </data:abc>data>

 

I want to delete all contents between "data:abc"data and </data:abc>. The XML tags are not displayed in the question after posting.

I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact?

I have to delete particular tags from an xml file. Sample xml below.


 
       <data:abc>
          <tag:action tag:language="name"/>
        </data:abc>

 

I want to delete all contents between "data:abc" and </data:abc>. I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact?

I have to delete particular tags from an xml file. Sample xml below.

       <data>
          <tag:action/>
        </data>

I want to delete all contents between data and /data. The XML tags are not displayed in the question after posting.

I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact?

deleted 5 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

I have to delete particular tags from an xml file. Sample xml below.


       <data:abc>
          <tag:action tag:language="name"/>
        </data:abc>

I want to delete all contents between "data:abc" and </data:abc>. I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0ns0, ns1ns1 and so on in new.xmlnew.xml.

Is there any way to modify the XML file keeping all other contents in tact? Please suggest.

I have to delete particular tags from an xml file. Sample xml below.


       <data:abc>
          <tag:action tag:language="name"/>
        </data:abc>

I want to delete all contents between "data:abc" and </data:abc>. I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact? Please suggest.

I have to delete particular tags from an xml file. Sample xml below.


       <data:abc>
          <tag:action tag:language="name"/>
        </data:abc>

I want to delete all contents between "data:abc" and </data:abc>. I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact?

Source Link
Akhitha
  • 43
  • 1
  • 2
  • 6

python xml parsing

I have to delete particular tags from an xml file. Sample xml below.


       <data:abc>
          <tag:action tag:language="name"/>
        </data:abc>

I want to delete all contents between "data:abc" and </data:abc>. I am able to do this by using remove() method in Python ElementTree xml parser. I am writing the modified contents to a new after the deletion of the element.

tree.write('new.xml');

The problem is that all the tag names in the original xml file are renamed to ns0, ns1 and so on in new.xml.

Is there any way to modify the XML file keeping all other contents in tact? Please suggest.