XPath using starts-with function

前端 未结 3 862
盖世英雄少女心
盖世英雄少女心 2020-12-30 20:17

I\'m writing Java on Android to retrieve data from XML file, but I\'ve got a problem. Consider this XML:


   2554-02

        
相关标签:
3条回答
  • 2020-12-30 20:30

    Use:

    /*/ITEM[starts-with(REVENUE_YEAR,'2552')]/REGION
    

    Note: Unless your host language can't handle element instance as result, do not use text nodes specially in mixed content data model. Do not start expressions with // operator when the schema is well known.

    0 讨论(0)
  • 2020-12-30 20:39

    Try this

    //ITEM/*[starts-with(text(),'2552')]/following-sibling::*
    
    0 讨论(0)
  • 2020-12-30 20:43

    Use:

    //REVENUE_YEAR[starts-with(.,'2552')]/../REGION/text() 
    
    0 讨论(0)
提交回复
热议问题