Hallo hab folgendes Problem und zwar hab ich einen Dom Parser geschrieben der ein XML Dokument einliest, mit der Transformator Klasse liest er das Dokument aus und erstellt daraus wieder eine XML Datei die folgt aussieht :
<myResortAttributeManagement>
<myResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>0</resortAttributeId>
<resortAttributeName>Sandstrand</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>1</resortAttributeId>
<resortAttributeName>Pool-Landschaft</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>2</resortAttributeId>
<resortAttributeName>Spa</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>3</resortAttributeId>
<resortAttributeName>Disco</resortAttributeName>
</dataLogic.ResortAttribute>
</myResortAttribute>
</myResortAttributeManagement>
<resortArrayList>
Ich möchte nun die einzelnen Tag attribute auslesen und in eine ArrayList speichern wie kann man da am besten vorgehn? also so kann ich auf die Tags zugreifen und wie dann am besten speichern in einer ArrayList?
Danke für die Hilfe
<myResortAttributeManagement>
<myResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>0</resortAttributeId>
<resortAttributeName>Sandstrand</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>1</resortAttributeId>
<resortAttributeName>Pool-Landschaft</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>2</resortAttributeId>
<resortAttributeName>Spa</resortAttributeName>
</dataLogic.ResortAttribute>
<dataLogic.ResortAttribute>
<resortAttributeId>3</resortAttributeId>
<resortAttributeName>Disco</resortAttributeName>
</dataLogic.ResortAttribute>
</myResortAttribute>
</myResortAttributeManagement>
<resortArrayList>
Ich möchte nun die einzelnen Tag attribute auslesen und in eine ArrayList speichern wie kann man da am besten vorgehn? also so kann ich auf die Tags zugreifen und wie dann am besten speichern in einer ArrayList?
Java:
NodeList knotenListe = doc.getElementsByTagName("resortAttributeId");
int anzahl = knotenListe.getLength();
for (int i = 0; i<anzahl; i++) {
knotenListe.item(i).getFirstChild().getNodeValue();
Danke für die Hilfe