Hallo ins Forum,
ich muss vorweg gestehen ich habe mich die Komplette letzte Woche erst mit Java beschäftigt. (bitte nehmt es mir also nicht Krum wie die Frage vielleicht Blöd ist.)
Da ich gesucht habe bei Google und auch hier im Forum und nicht so richtig fündig geworden bin kommt hier mal meine Frage.
Ich habe ein Projekt wo ich aus einem kleinen Tool (zugänglich leider nur für 2 Personen) mir die Informationen in ein *.xml Dokument exportieren kann.
Dieses Dokument da es glaube über 15k Zeilen hat wollte ich Parsen und das dann vielleicht über eine GUI oder über WEB Seiten Zugriff mit einem Suchfeld Durchsuchen und dann nur den einzelnen Wert + Child Elemente ausgeben.
Ich scheitere aber nun einfach schon beim Einlesen.
Ich zeig euch Exemplarisch auch mal die Exportierte *.xml
Ich hoffe ich hab nur ein Vertipper drin oder ich bin doch total Blöd
Freu mich auf ein bissel Hilfe
Sollte ich euch im Bezug auf Mediendesign oder gar bei der Fotografie helfen können immer her mit euren Fragen.
ich muss vorweg gestehen ich habe mich die Komplette letzte Woche erst mit Java beschäftigt. (bitte nehmt es mir also nicht Krum wie die Frage vielleicht Blöd ist.)
Da ich gesucht habe bei Google und auch hier im Forum und nicht so richtig fündig geworden bin kommt hier mal meine Frage.
Ich habe ein Projekt wo ich aus einem kleinen Tool (zugänglich leider nur für 2 Personen) mir die Informationen in ein *.xml Dokument exportieren kann.
Dieses Dokument da es glaube über 15k Zeilen hat wollte ich Parsen und das dann vielleicht über eine GUI oder über WEB Seiten Zugriff mit einem Suchfeld Durchsuchen und dann nur den einzelnen Wert + Child Elemente ausgeben.
Ich scheitere aber nun einfach schon beim Einlesen.
Java:
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.util.ArrayList;
public class AdminTool3Shape {
//Pfad und Name der XML Datei die Geparst werden soll
private static String XMLDateiName = "\\\\xxx.xxx.xxx.xxx\\xxxxx\\xxxxxxx\\xxxxxx\\07 - Projekte\\06 - Java\\3ShapeExport.xml";
private static String Site, Description, Dongle, Application, Attribute ;
private static ArrayList<String> liste;
private static ArrayList<SiteList> liste2;
public static void main(String[] args) throws Exception, Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
// Uebergebene XML-Datei parsen
Document dokument = builder.parse(new File(XMLDateiName));
dokument.getDocumentElement();
getAlleSite(dokument);
getAlleDescription(Dongle, Application, Attribute, dokument);
// DOM Baum durchlaufen und ausgeben
traversieren(dokument.getDocumentElement(), "");
}
private static void traversieren(Element d, String dongle) {
System.out.println(dongle + d.getNodeName());
// Kindelemente des uebergebenen Elements ermitteln
NodeList children = d.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node knoten = children.item(i);
// Knoten ist ein ELEMENT_NODE
if (knoten.getNodeType() == Node.ELEMENT_NODE)
// Rekursiver Aufruf von traversieren für aktuelles Element
traversieren((Element) knoten, dongle + " ");
// Knoten ist ein TEXT_NODE
else if (knoten.getNodeType() == Node.TEXT_NODE) {
String inhalt = knoten.getTextContent();
if (inhalt.trim().length() > 0) // leerer Inhalt?
System.out.println(dongle + " :" + inhalt);
} else
// kein ELEMENT_NODE, kein TEXT_NODE
System.out.println(dongle + knoten);
}
}
private static ArrayList<String> getAlleSite(Document dokument) {
// Alle Kindelemente mit dem Site Description einsammeln
NodeList siteNodes = dokument.getElementsByTagName("Site");
liste = new ArrayList<String>(siteNodes.getLength());
for (int i=0; i<siteNodes.getLength(); i++) {
// Node nach Element casten
Element siteElement = (Element) siteNodes.item(i);
// Neue Instanz von Site anlegen
Site abschnitt = new Site(null, Site, Description, Dongle, Application, Attribute, XMLDateiName);
// Kindelemente Description suchen, den Textinhalt als Description nehmen
NodeList node1 = siteElement.getElementsByTagName("Description");
Site.setDescription(node1.item(0).getTextContent());
// Analog für Dongle
NodeList node2 = siteElement.getElementsByTagName("Dongle");
Site.setDongle(node2.item(0).getTextContent());
Description=Site.getDescription();
Dongle=Site.getDongle();
liste.add(Description+" "+Dongle);
}
// Kontroll Ausgabe der Liste auf der Konsole
System.out.println("*** All Site ***");
System.out.println(liste);
return liste;
}
public static ArrayList<SiteList> getAdressenDaten(String Site, String Description, Document dokument){
NodeList site= dokument.getElementsByTagName("Site");
NodeList description= dokument.getElementsByTagName("Description");
NodeList Dongle= dokument.getElementsByTagName("Dongle");
NodeList Application=dokument.getElementsByTagName("Application");
NodeList Attribute=dokument.getElementsByTagName("Attribute");
liste2 = new ArrayList<SiteList>(liste.size());
for (int i =0;i<liste.size();i++){
String pSite=site.item(i).getTextContent();
String pDescription=description.item(i).getTextContent();
String pDongle=Dongle.item(i).getTextContent();
String pApplication=Application.item(i).getTextContent();
String pAttribute=Attribute.item(i).getTextContent();
SiteList s= new SiteList();
s.setSite(pSite);
s.setDescription(pDescription);
s.setDongle(pDongle);
s.setApplication(pApplication);
s.setAttribute(pAttribute);
liste2.add(site);
}
}
System.out.println(liste2);
return liste2;
}
public static void getAlleDescription (Document dokument) {
NodeList Site= dokument.getElementsByTagName("Site");
NodeList Description= dokument.getElementsByTagName("Description");
liste = new ArrayList<String> (Site.getLength());
for (int i=0; i<Site.getLength();i++){
Site.item(i).getTextContent();
Description.item(i).getTextContent();
liste.add(Site+" " +Description);
}
}
private static void getAlleDescription(String dongle2, String application2, String attribute2, Document dokument) {
}
public static String getXMLDateiName() {
return XMLDateiName;
}
public static void setXMLDateiName(String xMLDateiName) {
XMLDateiName = xMLDateiName;
}
public static String getSite() {
return Site;
}
public static void setSite(String site) {
Site = site;
}
public static String getDescription() {
return Description;
}
public static void setDescription(String description) {
Description = description;
}
public static String getDongle() {
return Dongle;
}
public static void setDongle(String dongle) {
Dongle = dongle;
}
public static String getApplication() {
return Application;
}
public static void setApplication(String application) {
Application = application;
}
public static String getAttribute() {
return Attribute;
}
public static void setAttribute(String attribute) {
Attribute = attribute;
}
}
Ich zeig euch Exemplarisch auch mal die Exportierte *.xml
XML:
<?xml version="1.0"?>
<SiteExport Version="1.0">
<CustomerName>Firma</CustomerName>
<SiteList>
<Site ID="09051">
<Description>000_XXX_1271101190</Description>
<ResellersCustomerNo></ResellersCustomerNo>
<ResellersCustomID1 Label="Custom ID 1"></ResellersCustomID1>
<ResellersCustomID2 Label="Custom ID 2"></ResellersCustomID2>
<ResellersCustomID3 Label="Custom ID 3"></ResellersCustomID3>
<Notes></Notes>
<CanReceive>True</CanReceive>
<Dongles>
<Dongle Number="1271101190">
<Application Name="DentalDesigner Premium">
<Attribute>Expired</Attribute>
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
<Attribute>Installed version: 2.8.8.4</Attribute>
</Application>
<Application Name="DentalManager">
<Attribute>Encryption enabled</Attribute>
<Attribute>Expired</Attribute>
<Attribute>Client points: 3</Attribute>
<Attribute>Options: Abutments OBSOLETE from 2010</Attribute>
<Attribute>Installed version: 2.8.8.4</Attribute>
</Application>
<Application Name="DentalManager Inbox module">
<Attribute>Expired</Attribute>
<Attribute>Client points: 3</Attribute>
</Application>
<Application Name="ScanIt Impression">
<Attribute>Saves limited</Attribute>
</Application>
<Application Name="Abutment Designer Module Save Limited DEMO">
<Attribute>Saves limited</Attribute>
</Application>
<Application Name="Removable Design Module">
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
</Application>
<Application Name="Implant Bars/Bridge Design Module">
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
</Application>
<Application Name="Model Builder (TRIOS scans only)">
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
</Application>
<Application Name="Model Builder (3rd Party scans)">
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
</Application>
<Application Name="Model Builder (Impression scans)">
<Attribute>Saves limited</Attribute>
<Attribute>Client points: 1</Attribute>
</Application>
</Dongle>
</Dongles>
<Connections>
<Connection ReceiverSiteID="14065">
<Notes></Notes>
<CreateDate>2012-06-25</CreateDate>
</Connection>
</Connections>
<Options>
<Option Name="RawSTL" Description="Raw STL CAD Output for all customers"/>
<Option Name="RK" Description="Rübeling und Klar CAD Output for all customers"/>
<Option Name="3DPrinter" Description="3D Printer CAD Output for all customers"/>
<Option Name="RestorationMill" Description="RestorationMill CAD Output for all customers"/>
<Option Name="BEGO" Description="BEGO CAD Output"/>
<Option Name="DentMill" Description="DentMill CAD Output for all customers"/>
<Option Name="RawSTLExceptLocked" Description="Raw STL (except locked) OBSOLETE! for all customers"/>
<Option Name="GeneralRPMachine" Description="RP machine with supports CAD Output for all customers"/>
<Option Name="Mandatory 1" Description="Mandatory 1"/>
<Option Name="WielandZeno40" Description="Zeno CAM 4.0 CAD Output"/>
<Option Name="3IImplantSignature1" Description="3I Implant Signature 1 for all customers"/>
<Option Name="FollowMe" Description="Follow Me CAD Output for all customers"/>
<Option Name="BEGO-Semados" Description="BEGO abutment kit"/>
<Option Name="SII_STLOutput" Description="ScanIt Impression STL output"/>
<Option Name="RawDCM" Description="Raw DCM CAD Output for all customers"/>
<Option Name="SIR_STLOutput" Description="ScanIt Restoration STL output"/>
<Option Name="Wieland-Abutments" Description="Wieland abutment kit for all customers"/>
<Option Name="VisualizationOutput" Description="Visualization output for all customers"/>
<Option Name="Camlog" Description="Camlog Implant Kit for all customers"/>
<Option Name="Neoss" Description="Neoss Implant Kit for all customers"/>
<Option Name="Avinent Protech Implant Library" Description="Avinent Protech Implant Library (Option D) for all customers"/>
<Option Name="BioHorizons" Description="Implantlibrary of BioHorizons for all customers"/>
<Option Name="ZimmerAbutmentKit" Description="Zimmer Abutment Kit (Option B) for all customers"/>
<Option Name="ZimmerImplantSignature1" Description="Zimmer Implant Signature 1 (Option B) for all customers"/>
<Option Name="Core3d Implant library" Description="Core3d Implant library (Option D) for all customers"/>
<Option Name="Jorge Test" Description="Jorge Test for all customers"/>
<Option Name="BEGOCrownLibrary" Description="BEGO Crown Library"/>
<Option Name="RawSTL" Description="Raw STL CAD Output"/>
<Option Name="GlidewellHybridKit" Description="GlidewellHybridKit for all customers"/>
<Option Name="GlidewellBarKit" Description="GlidewellBarKit for all customers"/>
<Option Name="BegoAbutmentKit" Description="BegoAbutmentKit for all customers"/>
<Option Name="GlidewellAnatomyLibrary" Description="GlidewellAnatomyLibrary for all customers"/>
<Option Name="Unlimited Implant Scanning" Description="Unlimited Implant Scanning"/>
<Option Name="TriosInbox" Description="Trios Inbox enabling option for all customers"/>
<Option Name="VertexDental Quint Denture SmileLibrary" Description="VertexDental Quint Denture SmileLibrary (Option C) for all customers"/>
<Option Name="Pala Smile library" Description="Pala® Smile library (Option D) for all customers"/>
</Options>
</Site>
</SiteList>
Ich hoffe ich hab nur ein Vertipper drin oder ich bin doch total Blöd
Freu mich auf ein bissel Hilfe
Sollte ich euch im Bezug auf Mediendesign oder gar bei der Fotografie helfen können immer her mit euren Fragen.