0

Running static analysis on my code it was pointed out that I shouldn't use Sun classes and use Java APIs instead.

What would be the correct Java API equivalent of the following code:

DeferredElementNSImpl nodes = (DeferredElementNSImpl) node;
Node transactionID = nodes.getElementsByTagName("id").item(0);

Where node is of type org.w3c.dom.Node

Samantha Catania
  • 5,116
  • 5
  • 39
  • 69

2 Answers2

1

You should cast node to org.w3c.dom.Element.

Farrandu
  • 371
  • 1
  • 7
-2

org.w3c.dom is not a Sun class. It is a w3c class.

The classes they want you to avoid are in packages like com.sun or occasionally sun.something

The org.w3c.dom is the standard api for doing any kind of DOM stuff in Java. It is not something to be written around.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138