Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spring-conversion-xml-parser
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christopher Cottier
spring-conversion-xml-parser
Commits
46e7c663
Commit
46e7c663
authored
Jul 21, 2021
by
Christopher Cottier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get node by name path method
parent
a80e62bc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
25 deletions
+21
-25
XMLParser.class
...on/spring-conversion-xml-parser/com/nisum/XMLParser.class
+0
-0
XMLParsingScript.class
...ng-conversion-xml-parser/com/nisum/XMLParsingScript.class
+0
-0
XMLParser.groovy
src/main/groovy/com/nisum/XMLParser.groovy
+14
-8
XMLParsingScript.groovy
src/main/groovy/com/nisum/XMLParsingScript.groovy
+7
-17
No files found.
out/production/spring-conversion-xml-parser/com/nisum/XMLParser.class
View file @
46e7c663
No preview for this file type
out/production/spring-conversion-xml-parser/com/nisum/XMLParsingScript.class
View file @
46e7c663
No preview for this file type
src/main/groovy/com/nisum/XMLParser.groovy
View file @
46e7c663
...
@@ -5,19 +5,25 @@ import groovy.xml.slurpersupport.GPathResult
...
@@ -5,19 +5,25 @@ import groovy.xml.slurpersupport.GPathResult
class
XMLParser
{
class
XMLParser
{
public
File
file
;
File
file
;
GPathResult
xmlNodes
;
static
void
main
(
String
[]
args
)
{
public
void
loadFile
(
String
fileLocation
){
file
=
new
File
(
fileLocation
);
}
public
GPathResult
createParser
()
{
return
new
XmlSlurper
().
parse
(
file
)
}
}
public
void
loadFile
(
String
fileLocation
){
public
GPathResult
getNodeByPath
(
String
[]
path
){
file
=
new
File
(
fileLocation
);
GPathResult
node
=
createParser
()
for
(
String
nodeName
:
path
)
{
node
=
node
.
"${nodeName}"
}
}
public
void
createParser
()
{
return
node
;
xmlNodes
=
new
XmlSlurper
().
parse
(
file
)
}
}
...
...
src/main/groovy/com/nisum/XMLParsingScript.groovy
View file @
46e7c663
...
@@ -2,30 +2,20 @@ package com.nisum
...
@@ -2,30 +2,20 @@ package com.nisum
import
groovy.xml.slurpersupport.GPathResult
import
groovy.xml.slurpersupport.GPathResult
//import groovy.xml.XmlSlurper
String
fileLocation
=
"./web.xml"
//
//def webApp = new XmlSlurper().parse("./web.xml")
//assert webApp instanceof groovy.util.Node
//
String fileLocation = "./web.xml"
//
eventually script will require absolute path from user input
String
fileLocation
=
"/Users/ccottier/Documents/ds-spring-conversion-tool/spring-conversion-xml-parser/src/main/groovy/com/nisum/web.xml"
//
String fileLocation = "/Users/ccottier/Documents/ds-spring-conversion-tool/spring-conversion-xml-parser/src/main/groovy/com/nisum/web.xml"
XMLParser
parser
=
new
XMLParser
()
XMLParser
parser
=
new
XMLParser
()
parser
.
loadFile
(
fileLocation
)
parser
.
loadFile
(
fileLocation
)
parser
.
createParser
()
GPathResult
webApp
=
parser
.
xmlNodes
String
[]
servPath
=
[
"servlet"
,
"servlet-name"
]
def
listenerNode
=
webApp
.
'listener'
def
servletNameNode
=
parser
.
getNodeByPath
(
servPath
)
def
contextParamNode
=
webApp
.
'context-param'
def
servletNode
=
webApp
.
'servlet'
def
servletMappingNode
=
webApp
.
'servlet-mapping'
//HashMap<String,String> hm = new HashMap<>();
println
(
servletNameNode
.
toString
())
println
(
servletNode
.
'servlet-name'
.
toString
())
def
listenerClass2
=
webApp
[
'@version'
]
//def listenerClass2 = webApp['@version']
//println(listenerClass2)
//println(listenerClass2)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment