If there is

HTML, change XPath

// div [@ id = "hoge"]
I would like to acquire only AAA because the contents ofspanare also acquired.
I'd be happy if you could tell me how to get rid of the child elements and get only your own elements.

  • Answer # 1

    '// div [@ id = "hoge"]/text ()'gets an array and the first element isspan>"\ n AAA \ n", you can get the second element as"\ nafterspan

    Leave blank characters after that.