We are reviewing a vendor who will output some data in an XML format.
I will then use python to convert the data to another format for
upload to another vendor. I'm having trouble with very basic steps
with the sample file they sent me.
My very simple test script is:
from xml.etree.Eleme ntTree import parse
tree = parse("sample.x ml")
print tree.findtext(" invoice_batch/batch_id/")
When I apply this to a very concatenated sample.xml with namespace (as
they send it to me)
<invoice_batch_ generic xmlns="http://tempuri.org/
invoice_batch_g eneric.xsd">
<invoice_batc h>
<batch_id>1</batch_id>
</invoice_batch>
</invoice_batch_g eneric>
The result I get is "None".
When I apply this to the same file with the namespace removed
<invoice_batch_ generic>
<invoice_batc h>
<batch_id>1</batch_id>
</invoice_batch>
</invoice_batch_g eneric>
The result is "1" which is what I would expect.
This is obviously just the very first step of what will be a much
larger process. The actual XML file is several pages long. I'm using
Python 2.5.2 (activestate) on Windows Vista.
I'm new to Python and newer to XML. So what am I missing? What am I
doing wrong?
Thanks --Joshua
I will then use python to convert the data to another format for
upload to another vendor. I'm having trouble with very basic steps
with the sample file they sent me.
My very simple test script is:
from xml.etree.Eleme ntTree import parse
tree = parse("sample.x ml")
print tree.findtext(" invoice_batch/batch_id/")
When I apply this to a very concatenated sample.xml with namespace (as
they send it to me)
<invoice_batch_ generic xmlns="http://tempuri.org/
invoice_batch_g eneric.xsd">
<invoice_batc h>
<batch_id>1</batch_id>
</invoice_batch>
</invoice_batch_g eneric>
The result I get is "None".
When I apply this to the same file with the namespace removed
<invoice_batch_ generic>
<invoice_batc h>
<batch_id>1</batch_id>
</invoice_batch>
</invoice_batch_g eneric>
The result is "1" which is what I would expect.
This is obviously just the very first step of what will be a much
larger process. The actual XML file is several pages long. I'm using
Python 2.5.2 (activestate) on Windows Vista.
I'm new to Python and newer to XML. So what am I missing? What am I
doing wrong?
Thanks --Joshua
Comment