On Jan 15, 3:49 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Gowri schrieb:
>
> > Hello,
>
> > I've been reading about ElementTreee and ElementPath so I could use
> > them to find the right elements in the DOM. Unfortunately neither of
> > these seem to offer XPath like capabilities where I can find elements
> > based on tag, attribute values etc. Are there any libraries which can
> > give me XPath like functionality?
>
> lxml does that.
>
> Diez

Hi Diez

I was trying lxml out and was unable to find any examples that would
help me parse an XML file with namespaces. For example, my XML file
looks like this:

<phedexData xmlns="http://a.b.com/phedex";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://a.b.com/phedex requests.xsd">
        <!--  Low priority replication request -->
        <request id="1234" last_update="1060199000.0">
                <status>
                        <approved>T1_RAL_MSS</approved>
                        <approved>T2_London_ICHEP</approved>
                        <disapproved>T2_Southgrid_Bristol</disapproved>
                        <pending/>
                        <move_pending/>
                </status>
                <subscription open="1" priority="0" type="replicate">
                        <items>
                                <dataset>/PrimaryDS1/ProcessedDS1/Tier</dataset>
                                        
<block>/PrimaryDS2/ProcessedDS2/Tier/block</block>
                        </items>
                </subscription>
        </request>
</phedexData>

If my Xpath query is //request, it obviously would not work. Is there
some sort of namespace registration etc. that is to be done before
issuing a query? Example code would help a lot.


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to