修改
This commit is contained in:
@@ -25,7 +25,7 @@ public class XmlUtil {
|
||||
* @param xPathPattern
|
||||
* @param newValue
|
||||
*/
|
||||
public void modifyXmlText(String xmlPath,String xPathPattern,String newValue){
|
||||
public Document modifyXmlText(String xmlPath,String xPathPattern,String newValue){
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder;
|
||||
Document document = null;
|
||||
@@ -60,6 +60,11 @@ public class XmlUtil {
|
||||
Element element = (Element) nodeList.item(i);
|
||||
element.setTextContent(newValue);
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public void writeDocument(Document document,String xmlPath){
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
|
||||
Transformer transformer = null;
|
||||
@@ -75,8 +80,8 @@ public class XmlUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new XmlUtil().modifyXmlText("/root/dev/workspace/micro-fast/boot-starter/pom.xml","//parent/version","1");
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
// new XmlUtil().modifyXmlText("/root/dev/workspace/micro-fast/boot-starter/pom.xml","//parent/version","1");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>boot-starter</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user