I am trying to use an XPath in the Firebug console to get a <span>
element's text content. The actual <span>
tag content is 'first name' with a space within as shown below:
<span class="vl-cell e-listview-container-mail-Col5" iscell="1">first name</span>
When I enter the XPath below into Firebug's command line
$x("//div[@id='tble-listview-container-mail']/div[2]/span[4]")[0].innerHTML
I get the following output:
"first name" // getting a for the space within the string 'first name'.
When I want to get the element containing this text like
$x("//div[@id='tble-listview-container-mail']/div[2]/span[text()='first name']")
I get this as output:
[] // output is returned as empty
Can someone tell how I can get the element if the inner text has a space within it?
Note that the
in the output is an indication that you have a non-breaking space between the two words and not a normal space.
Therefore the output array is empty when you search for the containing text first name
(with normal space). You need to search for first name
(with non-breaking space) instead. Ie the function call then looks like this:
$x("//div[@id='tble-listview-container-mail']/div[2]/span[text()='first name']")
Note: You can display HTML entities using their name or Unicode representation via the HTML panel options 'Show Entities As Names' and 'Show Entities As Unicode' .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.