Tool to find out XPath [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more

C# WatiN – Add an AlertDialogHandler to click ok button on every Alert dialog window

Hello Those who have used WatiN likely also used DialogHandlers. Well can someone teach me how can i assign a DialogHandler that will handle any Alert Box window.alert(), of a specific IE instance under WatiN control . The DialogHandler only has to click in the OK button for very alert dialog box, in that case … Read more

XPath – how do you select the child elements of a node?

I have an XmlDocument containing a XHTML table. I’d like to loop through it to process the table cells one row at a time, but the code below is returning all the cells in the nested loop instead of just those for the current row: XmlNodeList tableRows = xdoc.SelectNodes(“//tr”); foreach (XmlElement tableRow in tableRows) { … Read more

how to check parent of current node is root node or not in xslt?

I want to check the parent of current node is root node or not in Xslt.How i do that? Please Guide me to get out of this issue… Thanks & Regards, P.SARAVANAN Answer In XPath 1.0 (XSLT 1.0): not(parent::*) Or you may use: generate-id(..) = generate-id(/) In XPath 2.0 (XSLT 2.0): .. is root() AttributionSource … Read more

XPath: select tag with empty value

How I can find in XPath 1.0 all rows with empty col name=”POW”? <row> <col name=”WOJ”>02</col> <col name=”POW”/> <col name=”GMI”/> <col name=”RODZ”/> <col name=”NAZWA”>DOLNOŚLĄSKIE</col> <col name=”NAZDOD”>województwo</col> <col name=”STAN_NA”>2011-01-01</col> </row> I tried many solutions. Few times in Firefox extension XPath Checker selection was ok, but lxml.xpath() says that expression is invalid or just returns no rows. … Read more

Get children of an element without the text nodes

I am using Nokogiri with Ruby to interpret the contents of an XML file. I would like to get an array (or similar) of all elements that are direct children of <where> in my example. However, I am getting various text nodes (e.g. “\n\t\t\t”), which I do not want. Is there any way I can … Read more

How to select all empty elements with XPath

Assume the following markup: <html> <body> <p> <strong> </strong> <strong> </strong> <strong><em>Bar</em> </strong> <strong><em> </em> </strong> </p> </body> </html> How can I get the following elements with a XPath query? <strong> </strong> <strong> </strong> <strong><em> </em> </strong> I’ve thought it would something like //*[normalize-space(text()) = ” and not(node())] for the first both cases but it’s … Read more

selecting current element name in XSLT

I need to output the element name which is being returned after applying the xpath expression for example <xsl:for-each select=”//element”> <xsl:value-of select=”**{elementname}**”></xsl:value-of> <xsl:text>:</xsl:text> <xsl:value-of select=”current()”/> <xsl:value-of /> </xsl:for-each> How can i replace {elementname} to some xpath so that I can get the element name instead of current value Answer <xsl:value-of select=”name()” /> Side note: Avoid … Read more

powershell xml xpath

In Powershell, suppose I have the following xml: <Users> <User Name=”Foo”> <Friends> <Friend Name=”Bar”/> </Friends> </User> <User Name=”Foo2″ /> <User Name=”Foo3″> <Friends> <Friend Name=”Bar”/> </Friends> </User> </Users> How can I get all the users that have a “Bar” as a friend? (In this example it would be Foo,Foo3). Should I use xpath? Thanks! Answer I … Read more