Good I am trying to show the content of an XML through the JDOM library, but apparently it is not showing me the sub-nodes of a certain field of the XML file, I do not know if the solution I am trying to implement is quite new in this parceo of XML documents, I leave the code.
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File( "E:\Desarollo\AED\workspace\Ficheros\libros.xml" );
try
{
Document document = (Document) builder.build( xmlFile );
Element rootNode = document.getRootElement();
List list = rootNode.getChildren( "Libro" );
for ( int i = 0; i < list.size(); i++ ) {
Element Libros = (Element) list.get(i);
String isbn = Libros.getAttributeValue("ISBN");
String titulo = Libros.getAttributeValue("Titulo");
System.out.println( "Titulo: " + titulo+" "+"ISBN= "+isbn );
List<Element> lista_campos = Libros.getChildren();
for ( int j = 0; j < lista_campos.size(); j++ ) {
Element campo = (Element)lista_campos.get( j );
String Ejemplar = campo.getChildTextTrim("Ejemplar");
System.out.println(Ejemplar);
String Autor = campo.getChildTextTrim("Autor");
System.out.println(Autor);
}
}
And this is giving me the following console output
As you can see there are certain nodes that I put them to NULL my doubt is as follows as I get to print all the nodes not only the first, I leave you also the original XML file.
Any kind of help or advice to modify the code will be welcome thanks in advance community.