Using NodeIterator to read XML file
Module 6
Create an XML document containing the employee details of an
organization. Then create an application, which uses the DOM parser to
parse the XML document into a DOM tree and traverses through it. The
application should implement the TreeWalker interface to traverse all
the nodes present in the DOM tree and print the value of the nodes.
Xml file
Main method()
Creating an object, parser of DocumentBuilder class, then check if the parser supports traversal 2.0 or not , after that create a Document object , doc using parser to read employee.xml
Create a NodeIterator object, iterator from the object doc
Use loop to use object iterator for display node content
Result:
Không có nhận xét nào:
Đăng nhận xét