Verify XML Element Name with dom\GetElementsByTagName.java

Q

How to verify if an XML contains a specific element with dom\Writer.java provided in the Apache Xerces package?

✍: FYIcenter

A

You can verify if an XML contains a specific element with dom\Writer.java provided in the Apache Xerces package as shown below.

Compile and run dom\Writer.java with "-e" option to search for XML elements by name:

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\javac 
   dom\GetElementsByTagName.java

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .;..\xercesSamples.jar;..\xercesImpl.jar;..\xml-apis.jar 
   dom.GetElementsByTagName -e ID User.xml

<ID>

 

dom\ElementPrinter.java - Apache Xerves DOM Sample

dom\GetElementsByTagName.java - Apache Xerves DOM Sample

Using Apache Xerces DOM Sample Programs

⇑⇑ FAQ for Apache Xerces XML Parser

2017-11-11, 9446🔥, 0💬