0
My main (parser) code is this way:
public class pFormasDePagamento {
public static void parseXML(String xml)
throws ParserConfigurationException, SAXException, IOException {
InputSource is = new InputSource(new StringReader(xml));
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
String valFormaOutros = doc.getElementsByTagName("VALOR").item(0)
.getTextContent();
String descForma = doc.getElementsByTagName("DESCRICAO").item(0)
.getTextContent();
String valForma = doc.getElementsByTagName("VALOR").item(1)
.getTextContent();
String descForma1 = doc.getElementsByTagName("DESCRICAO").item(1)
.getTextContent();
String valForma1 = doc.getElementsByTagName("VALOR").item(2)
.getTextContent();
String descForma2 = doc.getElementsByTagName("DESCRICAO").item(2)
.getTextContent();
String valForma2 = doc.getElementsByTagName("VALOR").item(3)
.getTextContent();
String descForma3 = doc.getElementsByTagName("DESCRICAO").item(3)
.getTextContent();
String valForma3 = doc.getElementsByTagName("VALOR").item(4)
.getTextContent();
String descForma4 = doc.getElementsByTagName("DESCRICAO").item(4)
.getTextContent();
String valForma4 = doc.getElementsByTagName("VALOR").item(5)
.getTextContent();
String descForma5 = doc.getElementsByTagName("DESCRICAO").item(5)
.getTextContent();
String valForma5 = doc.getElementsByTagName("VALOR").item(6)
.getTextContent();
}}
I would like to save all these strings (valForma1...5) to be reused in others. Java
How can I fix this?
how would I make the call then Rafael?
– Renan Serrão Nogueira
how can I call separate variables @Rafaeltelles?
– Renan Serrão Nogueira
It could be something like "Build up[] forms = pFormasDePackage.parseXML(xml)", and in this array you would have all xml objects.
– Rafael Telles