I don't want something static, because the list can change, and I can have much more nodes. I want something dinamic. I'm using 'split' to separate the list, but I haven't get do the correct function. Probably is very easy, but I want to see done to understand better the Api and continue doing more things with the api.
<?xml version="1.0" encoding="UTF-8"?> <Agendas> <Cuenta label="Persona1" id="1"> <node label="Nombre" id="x"> <node label="Apellido" id="x"> <node label="Segundo" id="x"/> </node> </node> <node label="Nombre2" id="x"> <node label="Apellido" id="x"/> <node label="Apellido2" id="x"/> </node> </Cuenta> </Agendas>
Is not the best solution, I prefer create a XML with JDom but I can't. I someone want help me, I will thank you, but I will use my old function, because I can't create the new because I'm thinking in the old and Jdom is not the same.
SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(data.getBytes()));//data= my xml
I can't do the last line. If I use the bouilder that I put in the before post I can't because I get a document, not and element. I can do something like this with element?
String xml = "<account>" + " <country name=\"Japan\" capital=\"Tokyo\"/>" + " <country name=\"France\" capital=\"Paris\"/>" + "</account>"; Document doc = new Document(); Element root = new Element("Accounts"); doc.addContent(root) root.addContent(xml);