e aki mi error
Código:
el codigo java completo es:.... while (IGeneral.hasNext()){ Element EGeneral = (Element)IGeneral.next(); System.out.println("contenido Gral: "+EGeneral.getName()); Element identifier = EGeneral.getChild("identifier"); //EN LA LINEA ANTERIOR ME MUESTRA ERROR, java.lang.NullPointerException System.out.println(identifier.getText()); }
Código:
el codigo xml es el siguiente:import java.io.*; import java.util.*; import org.jdom.*; import org.jdom.input.*; import org.jdom.output.*; public class leerXML{ public static void main(String[] args) { try { SAXBuilder builder=new SAXBuilder(false); Document doc=builder.build("C:/OBJETOS/imsmanifest.xml"); Element raiz=doc.getRootElement(); List equipos=raiz.getChildren(); Iterator i = equipos.iterator(); while (i.hasNext()){ Element e= (Element)i.next(); if (e.getName().equals("metadata")){ List Lmeta = e.getChildren(); Iterator Imeta = Lmeta.iterator(); Element Emeta = (Element)Imeta.next(); System.out.println("contenido metadata: "+Emeta.getName()); List Lmeta1 = Emeta.getChildren(); System.out.println("lista meta: "+Lmeta.size()); Iterator Imeta1 = Lmeta1.iterator(); while (Imeta1.hasNext()){ Element Emeta1 = (Element)Imeta1.next(); //System.out.println("contenido lom: "+Emeta1.getName()); if (Emeta1.getName().equals("general")){ List LGeneral = Emeta1.getChildren(); Iterator IGeneral = LGeneral.iterator(); while (IGeneral.hasNext()){ Element EGeneral = (Element)IGeneral.next(); System.out.println("contenido Gral: "+EGeneral.getName()); Element identifier = EGeneral.getChild("identifier"); //EN LA LINEA ANTERIOR ME MUESTRA ERROR, java.lang.NullPointerException System.out.println(identifier.getText()); } } } } } }catch (Exception e){ e.printStackTrace(); } } }
Código:
<?xml version="1.0" encoding="UTF-8"?> <!--This is a Reload version 2.0.2 SCORM 1.2 Content Package document--> <!--Spawned from the Reload Content Package Generator - http://www.reload.ac.uk--> <manifest xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_rootv1p2p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2" identifier="MANIFEST-1B8C961E-599F-278E-7497-F30205437F0E" xsi:schemaLocation="http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd"> <metadata> <imsmd:lom xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"> <imsmd:general> <imsmd:identifier>Walson Yussan Zuñiga Mosquera</imsmd:identifier> <imsmd:title> <imsmd:langstring xml:lang="en">Paquete reutilizables para enseñar a incorporar Scorm a Moodle</imsmd:langstring> </imsmd:title> <imsmd:catalogentry> <imsmd:catalog>Objetos de Aprendizaje para Edugrupotex</imsmd:catalog> <imsmd:entry> <imsmd:langstring xml:lang="en" /> </imsmd:entry> </imsmd:catalogentry> <imsmd:language>es</imsmd:language> <imsmd:description> <imsmd:langstring xml:lang="en">Paquete Scorm a Moodle</imsmd:langstring> </imsmd:description> <imsmd:keyword> <imsmd:langstring xml:lang="en">SCORM, RELOAD EDITOR, PAQUETES REUTILIZABLES, OBJETOS DE APRENDIZAJE</imsmd:langstring> </imsmd:keyword> <imsmd:structure> <imsmd:source> <imsmd:langstring xml:lang="en">LOMv1.0</imsmd:langstring> </imsmd:source> <imsmd:value> <imsmd:langstring xml:lang="x-none">Collection</imsmd:langstring> </imsmd:value> </imsmd:structure> <imsmd:aggregationlevel> <imsmd:source> <imsmd:langstring xml:lang="en">LOMv1.0</imsmd:langstring> </imsmd:source> <imsmd:value> <imsmd:langstring xml:lang="x-none">1</imsmd:langstring> </imsmd:value> </imsmd:aggregationlevel> </imsmd:general> <imsmd:lifecycle> <imsmd:version> <imsmd:langstring xml:lang="en">01</imsmd:langstring> </imsmd:version> <imsmd:contribute> <imsmd:role> <imsmd:source> <imsmd:langstring xml:lang="en">LOMv1.0</imsmd:langstring> </imsmd:source> <imsmd:value> <imsmd:langstring xml:lang="x-none">Author</imsmd:langstring> </imsmd:value> </imsmd:role> <imsmd:date> <imsmd:datetime>11 de Abril de 2009</imsmd:datetime> </imsmd:date> </imsmd:contribute> </imsmd:lifecycle> <imsmd:technical> <imsmd:format>application/x-shockwave-flash</imsmd:format> <imsmd:size>3</imsmd:size> <imsmd:requirement> <imsmd:type> <imsmd:source> <imsmd:langstring xml:lang="en">LOMv1.0</imsmd:langstring> </imsmd:source> <imsmd:value> <imsmd:langstring xml:lang="x-none">Browser</imsmd:langstring> </imsmd:value> </imsmd:type> <imsmd:name> <imsmd:source> <imsmd:langstring xml:lang="en">LOMv1.0</imsmd:langstring> </imsmd:source> <imsmd:value> <imsmd:langstring xml:lang="x-none">Microsoft Internet Explorer</imsmd:langstring> </imsmd:value> </imsmd:name> </imsmd:requirement> </imsmd:technical> </imsmd:lom> </metadata> <organizations default="ORG-C35E712B-0449-9159-7142-0E934C211DAD"> <organization identifier="ORG-C35E712B-0449-9159-7142-0E934C211DAD" structure="hierarchical"> <title>Organization</title> <item identifier="ITEM-8062B5B9-4CF3-9881-EF81-0FF55A665F84" identifierref="RES-DC6BB503-0E78-CC2E-5F06-0DA21B72F643" isvisible="true"> <title>Presentación</title> </item> <item identifier="ITEM-3EEA9A8E-87FF-30CE-52A4-106C46D225AA" identifierref="RES-A933EAB7-7044-0F78-BBA8-40FA07DD4752" isvisible="true"> <title>Contenido</title> </item> <item identifier="ITEM-DA2BCEE6-96DE-8FB3-AC41-AEEC467300BA" identifierref="RES-5C07CEAF-2A84-5C44-7D7C-2BAE7C7D340B" isvisible="true"> <title>Evaluación</title> </item> <item identifier="ITEM-130DB6E6-90F8-E821-F360-D22C79029A15" identifierref="RES-9DF7CCAB-6BB2-4029-A963-FD284E3B17C5" isvisible="true"> <title>Metadata</title> </item> </organization> </organizations> <resources> <resource identifier="RES-DC6BB503-0E78-CC2E-5F06-0DA21B72F643" type="webcontent" adlcp:scormtype="sco" href="principal.html"> <file href="principal.html" /> </resource> <resource identifier="RES-A933EAB7-7044-0F78-BBA8-40FA07DD4752" type="webcontent" adlcp:scormtype="sco" href="index.html"> <file href="index.html" /> </resource> <resource identifier="RES-9DF7CCAB-6BB2-4029-A963-FD284E3B17C5" type="webcontent" adlcp:scormtype="sco" href="metadata.html"> <file href="metadata.html" /> </resource> <resource identifier="RES-5C07CEAF-2A84-5C44-7D7C-2BAE7C7D340B" type="webcontent" adlcp:scormtype="sco" href="Temp/Temp.html"> <file href="Temp/Temp.html" /> <file href="Temp/swf.js" /> <file href="Temp/Temp.swf" /> </resource> </resources> </manifest>