I am new to XPath, but I can see how powerful it is. I am looking at the source code of this link and simply want to extract the contents and username from the following tw
Use:
/*/head/meta[@name='description']/@content
This still selects an attribute node, but probably there is an easy way in your PL to get the string value of the attribute.
To get just the string value, use:
string(/*/head/meta[@name='description']/@content)
Do note: Using the //
abbreviation may result in very slow evaluation of the XPath expression, because it may cause a linear traversal of a whole (sub)tree.
Always avoid using //
if the structure of the XML document is statically known .
You're close. This should do it.
//head/meta[@name=\"description\"]/@content
The brackets are constraining the choice of meta tags, but you still have to specify the attribute you want.