Skip to content
Advertisement

Tag: dom4j

How to add a default name space with dom4j?

I would like to add a default name space to the root element of a XML document using dom4j, like in the following snippet. What is the correct way to do this with dom4j? The dom4j API does provide the method Element#addNamespace but the javadoc tells that the prefix may not be blank. The following code will result in the

TransformerFactory still vulnerable to XXE attacks

I have a method like below. I’ve set the FEATURE_SECURE_PROCESSING to true. When I run my unit test below, I can list the files under project directory, meaning it is vulnerable to XXE attacks. How can I secure the TransformerFactory to such attacks? Answer You’re supplying a DOMSource to the TransformerFactory, so the DTD was processed before the TransformerFactory came

Java – Dom4j Select Child Node

I use Dom4j to parse XML data.. How can I get pos value in child node tileX, tileY, and skip if empty? data/background_item.xml: Java code: Answer Inside your while loop, it should looks like this: To skip the empty, just check whether the xTileEle is null.

Advertisement