python xpath xml namespaces|How does XPath deal with XML namespaces?

https://blog.csdn.net/weixin_30364147/article/details/97049936?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-0&spm=1001.2101.3001.4242

 

https://stackoverflow.com/questions/40796231/how-does-xpath-deal-with-xml-namespaces

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://www.nexacro.com/platform/dataset" ver="5000">
    <Parameters>
        <Parameter id="HEDPAG" type="string"></Parameter>
        <Parameter id="HEDNEX" type="string"></Parameter>
        <Parameter id="HEDRTN" type="string"></Parameter>
        <Parameter id="HEDMSG" type="string"></Parameter>
        <Parameter id="UPDATE_CNT" type="string"></Parameter>
    </Parameters>
    <Dataset id="OUT1">
        <ColumnInfo>
        </ColumnInfo>
        <Rows>
        </Rows>
    </Dataset>
</Root>

 

 

 

Python (Scrapy):

response.selector.register_namespace('i', 'http://schema.intuit.com/finance/v3')
response.xpath('/i:IntuitResponse/i:QueryResponse').getall()

 

posted @ 2021-05-18 18:03  AngDH  阅读(69)  评论(0编辑  收藏  举报