Estoy escribiendo Java en Android para recuperar datos del archivo XML, pero tengo un problema. Considere este XML:Xpath usando la función starts-with
<ITEM>
<REVENUE_YEAR>2554-02</REVENUE_YEAR>
<REGION>Central</REGION>
</ITEM>
<ITEM>
<REVENUE_YEAR>2552-02</REVENUE_YEAR>
<REGION>Central</REGION>
</ITEM>
<ITEM>
<REVENUE_YEAR>2552-03</REVENUE_YEAR>
<REGION>Central</REGION>
</ITEM>
¿Cómo puedo obtener todos los elementos en años que comienzan con 2552.-Probé:
//REVENUE_YEAR[starts-with(.,'2552')]/text()
Funciona, pero cuando intenté:
//REVENUE_YEAR[starts-with(.,'2552')]/REGION/text()
no funciona
Yo no lo entiendo ... ¿por qué utilizar/*/nuevo? Acabo de tener un problema similar con XPath en Selenium y agregué el * en lugar de mi // inicial y también funciona: GetByxPath (string.Format ("/ */tbody [@ id = 'someContainer']/tr/td [ 1]/a (starts-with (@href, {0}) ","/Customers/")); – PositiveGuy
Velocidad. // es muy lenta. Siempre quiere buscar desde arriba si puede porque es mucho más rápido. – PRMan