Hello,

Is it possible to write xpath expressions that will query a web server's web.xml like this one :

<web-app>
 <display-name>My Application</display-name>
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.mycompany.MyServlet</servlet-class>
  </servlet>

  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/first</url-pattern>
  </servlet-mapping>

</web-app>

I would want to know if a particular web.xml has certain set of tags present or not. Like <servlet> and </servlet>
And if yes to get their count.
How can this be achieved using XPath expressions?

Tahnks.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
  <xsl:param name="find">servlet</xsl:param>

  <xsl:output method="text" encoding="utf-8"/>

  <xsl:template match="node()">
    <xsl:value-of select="count(//*[local-name()=$find])"/>
    <xsl:text>&#xa;</xsl:text>
  </xsl:template>

</xsl:stylesheet>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.