Commit 2b45023b authored by Christopher Cottier's avatar Christopher Cottier

xml scraping with groovy practice

parent b4db64d9
File added
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets, basically provides parameters to the entire web application-->
<!--see https://docs.spring.io/spring-framework/docs/3.0.0.M3/reference/html/ch19s02.html-->
<context-param>
<!--param gives the location of the root context.-->
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-context.xml</param-value>
</context-param>
<!-- root web-application-context for the web-application and puts it in the ServletContext-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- specifies which java servlet should be invoked for a url-->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
import groovy.xml.XmlSlurper
def webApp = new XmlSlurper().parse("./web.xml")
//assert webApp instanceof groovy.util.Node
def listenerClass = webApp.'listener'.'listener-class'.toString()
println(listenerClass)
def listenerClass2 = webApp['@version']
println(listenerClass2)
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets, basically provides parameters to the entire web application-->
<!--see https://docs.spring.io/spring-framework/docs/3.0.0.M3/reference/html/ch19s02.html-->
<context-param>
<!--param gives the location of the root context.-->
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-context.xml</param-value>
</context-param>
<!-- root web-application-context for the web-application and puts it in the ServletContext-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- specifies which java servlet should be invoked for a url-->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment