S
saif.shakeel
HI,
The following code is for replacing the strings localid with
"datapackageid" in an xml document.:
from xml.etree.ElementTree import ElementTree as et
file_input = raw_input("Enter The ODX File Path:")
(shortname,ext)=os.path.splitext(file_input)
test_file=shortname+"testxml.xml"
input_xml = open(file_input,'r')
tree = et.parse(input_xml)
for t in tree.getiterator("SERVICEPARAMETER"):
if t.get("Semantics") == "localId":
t.set("Semantics", "dataPackageID")
tree.write(test_file)
The python ver is 2.5.there is no module error
now,but when i run i get this error:
Traceback (most recent call last):
File "C:\Documents and Settings\pzchfr\Desktop\test.py", line 12, in
<module>
tree = et.parse(input_xml)
TypeError: unbound method parse() must be called with ElementTree
instance as first argument (got file instance instead)
I am passing the input file from user to be parsed
which seems to be incorrect,Can someone help me.
Thanks
The following code is for replacing the strings localid with
"datapackageid" in an xml document.:
from xml.etree.ElementTree import ElementTree as et
file_input = raw_input("Enter The ODX File Path:")
(shortname,ext)=os.path.splitext(file_input)
test_file=shortname+"testxml.xml"
input_xml = open(file_input,'r')
tree = et.parse(input_xml)
for t in tree.getiterator("SERVICEPARAMETER"):
if t.get("Semantics") == "localId":
t.set("Semantics", "dataPackageID")
tree.write(test_file)
The python ver is 2.5.there is no module error
now,but when i run i get this error:
Traceback (most recent call last):
File "C:\Documents and Settings\pzchfr\Desktop\test.py", line 12, in
<module>
tree = et.parse(input_xml)
TypeError: unbound method parse() must be called with ElementTree
instance as first argument (got file instance instead)
I am passing the input file from user to be parsed
which seems to be incorrect,Can someone help me.
Thanks