1
1
package com .baeldung .xml ;
2
2
3
+ import static com .baeldung .xml .SecureDocumentBuilderFactory .newSecureDocumentBuilderFactory ;
4
+
3
5
import java .io .File ;
4
6
import java .io .FileInputStream ;
5
7
import java .io .IOException ;
@@ -31,7 +33,7 @@ public NodeList getFirstLevelNodeList() {
31
33
NodeList nodeList = null ;
32
34
try {
33
35
FileInputStream fileIS = new FileInputStream (this .getFile ());
34
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ();
36
+ DocumentBuilderFactory builderFactory = newSecureDocumentBuilderFactory ();
35
37
36
38
DocumentBuilder builder = builderFactory .newDocumentBuilder ();
37
39
@@ -52,7 +54,7 @@ public NodeList getFirstLevelNodeList() {
52
54
public Node getNodeById (String id ) {
53
55
Node node = null ;
54
56
try {
55
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ();
57
+ DocumentBuilderFactory builderFactory = newSecureDocumentBuilderFactory ();
56
58
57
59
DocumentBuilder builder = builderFactory .newDocumentBuilder ();
58
60
@@ -73,7 +75,7 @@ public Node getNodeById(String id) {
73
75
public NodeList getNodeListByTitle (String name ) {
74
76
NodeList nodeList = null ;
75
77
try {
76
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ();
78
+ DocumentBuilderFactory builderFactory = newSecureDocumentBuilderFactory ();
77
79
78
80
DocumentBuilder builder = builderFactory .newDocumentBuilder ();
79
81
@@ -97,7 +99,7 @@ public NodeList getElementsByDate(String date) {
97
99
NodeList nodeList = null ;
98
100
99
101
try {
100
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ();
102
+ DocumentBuilderFactory builderFactory = newSecureDocumentBuilderFactory ();
101
103
102
104
DocumentBuilder builder = builderFactory .newDocumentBuilder ();
103
105
@@ -120,7 +122,7 @@ public NodeList getElementsByDate(String date) {
120
122
public NodeList getAllTutorials () {
121
123
NodeList nodeList = null ;
122
124
try {
123
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ();
125
+ DocumentBuilderFactory builderFactory = newSecureDocumentBuilderFactory ();
124
126
builderFactory .setNamespaceAware (true );
125
127
DocumentBuilder builder = builderFactory .newDocumentBuilder ();
126
128
0 commit comments