Xpath zugriff auf Attribute

P

Pagaty

Gast
Hallo,

ich versuche eine Anwendung in Java zu entwickeln, bei der ich Xpath einsetzen möchte.

Ich bin nun schon mehrere Seiten/Codebeispiele durchgegangen, hänge aber an einer Stelle.
Fehler werden keine ausgegeben.
Aber -> es kommt nicht das was ich erwarte zurück.


das xml File:
Code:
<Rennen>
  <Zeitstempel>
    24.11.2012_15:50:00
    <Fahrer1>
      Chrissi
      <Bahn1 f1_b1_runden="12" f1_b1_zeit="9,775" />
    </Fahrer1>
  </Zeitstempel>
</Rennen>

der Code
Java:
SAXBuilder builder = new SAXBuilder();
                Document datei = new Document();
                //Einlesen einer Datei
                try {
                        datei = builder.build("races.xml");
                } catch (JDOMException f) {
                        System.out.println(f.getMessage());
                        f.printStackTrace();
                } catch (IOException f) {
                        System.out.println(f.getMessage());
                        f.printStackTrace();
                }
                System.out.println("1");
                Element rennen= datei.getRootElement();
                List race = rennen.getChildren();
                XPathExpression <Object> xpath = XPathFactory.instance().compile("/rennen/Zeitstemptel/Fahrer1/Bahn1/@f1_b1_runden");
                List<Object> runden = xpath.evaluate( datei );
                System.out.println(xpath);
                for (Object object : runden){
                	System.out.println("3");
                	Attribute attribute = (Attribute) object;
                	System.out.println(attribute.getValue());
                }
            }

das ist die Ausgabe
Code:
1
[XPathExpression: 1 namespaces and 0 variables for query /rennen/Zeitstemptel/Fahrer1/Bahn1/@f1_b1_runden]

Bis zum System.out 3 komme ich nicht, weil ich keine "Daten" habe. (richtig?)
Ich hatte mir eigendlich vorgestellt, das ich mit dieser Variante auf "f1_b1_runden" zugreifen bzw. danach sortieren kann.

Über Anregungen bin ich Dankbar.

MfG
Pagaty
 
N

nillehammer

Gast
Case-Fehler im XPath-Ausdruck:
Java:
"/rennen/Zeitstemptel/Fahrer1/Bahn1/@f1_b1_runden");
Aber:
[XML]<Rennen>[/XML]
das R muss groß
 

Pagaty

Mitglied
Hallo nillehammer,

danke für die schnelle Antwort.
Uiuiui, das hab ich übersehen - seit 2 Tagen....

Super. Hab sogar gleich noch nen 2. Tippfehler entdeckt.
(Zeitstempel)

Danke

Pagaty
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
Kirby.exe Probleme mit XML XPATH Select XML & JSON 3
B XPath soll XML liefern XML & JSON 7
O XPATH Problem - Anfänger XML & JSON 4
M dom4j unberechtigte Invalid XPath expression XML & JSON 12
W XPath schreiben XML & JSON 1
P HTML XPath XML & JSON 1
S Ersatz für die veraltete Klasse XPath XML & JSON 1
C XPath: Alle Kinder in einer Schleife auslesen XML & JSON 2
P "XPath is deprecated" XML eclipse XML & JSON 3
G HtmlUnit XPath XML & JSON 5
D XPath-Query XML & JSON 2
I XPath Namensräume und auslesen einzelner Knoten XML & JSON 3
AMStyles XPATH Befehl SVG Java XML & JSON 2
G xpath: in Kindelement zwei Attribut-Werte auslesen XML & JSON 2
G xpath: Inhalt eines Kindelements auslesen XML & JSON 2
H ChildNode via XPath ansprechen XML & JSON 2
G JDOM - aus Children-Liste ein Child direkt ansprechen ohne XPath? XML & JSON 9
S Attribute von Elementen auslesen mit XPath XML & JSON 2
T Xpath & JDOM Element Pfad ausgeben XML & JSON 2
W XPath + Inhalt aus <td> XML & JSON 2
R XPath - frage zur Adressierung XML & JSON 3
reibi XPath XML & JSON 14
M xPath liefert leeres Nodeset XML & JSON 2
M Probleme mit XPath bei Java XML & JSON 5
W Element mit XPath @id ermitteln wenn nur ein teil der id bekannt ist XML & JSON 2
F XPath-Problem mit DOM4J XML & JSON 8
T XPath Problem: finden einer Node nach Attributswert XML & JSON 2
O XPATH gesucht XML & JSON 6
G XPATH-Frage XML & JSON 2
L Element manipulieren in einem DOMResult per XPath XML & JSON 10
P XPath und Namespaces XML & JSON 3
G XPath - replace function funktioniert nicht XML & JSON 3
E XPATH-Ausdruck mit not XML & JSON 4
E Wieso liefert dieser XPATH-Ausdruck nicht die richtige Anzahl Treffer? XML & JSON 8
M XPath Ausdruck validieren XML & JSON 2
N XPath Adressierung XML & JSON 7
F XPath frage XML & JSON 4
B Optionaler XPath pfad XML & JSON 2
B XPath frage XML & JSON 2
T Frage zu XQuery (XQJ) / XPath XML & JSON 2
P XPath Problem XML & JSON 2
S Problem mit XPath XML & JSON 4
T Mit XPATH finden und dann änder XML & JSON 2
T EXSD auslesen mit XPath und JDOM XML & JSON 8
G XPath gesucht für Tag mit konkretem Content XML & JSON 2
A XPath Problem XML & JSON 2
C XPath in JDOM klappt nicht XML & JSON 2
T Prbolem XPath XML & JSON 2
X Xpath, alle Element die mit "user" beginnen auswäh XML & JSON 2
loadbrain XPath Problem XML & JSON 2
M brauche große XML-Datei für XPath-Tests XML & JSON 4
M JDOM und XPath, zu Element zugehörigen XPath-Ausdruck XML & JSON 5
F JDOM und XPath - Problem mit Namespace ohne Prefix XML & JSON 5
F hilfe bei xpath-ausdruck XML & JSON 2
K java + xpath -> performanceproblem XML & JSON 9
H Xpath kindelemente auslesen XML & JSON 2
S Xml zurück in xpath wandeln XML & JSON 8
G Frage zu XPath XML & JSON 2
flashfactor Filtern mittels XPATH XML & JSON 4
M XSL/XPath - Nur ersten Wert mit selben Attribut XML & JSON 4
M XPath Problem im Zusammenhang mit document() XML & JSON 2
M Frag zu xsl:when beziehungsweise XPath XML & JSON 3
F JDom und XPath XML & JSON 12
C xpath funktioniert nicht XML & JSON 5
M XPATH und RSS (Problem namespaces) XML & JSON 7
P nochmal XPath :-) XML & JSON 22
P XPath . XML & JSON 2
T Rekursiver Verzeichniss Baum in XML & XPath XML & JSON 4
clemson xpath mit jdom XML & JSON 2
Wildcard xpath Parser XML & JSON 8
MAGI XML Server Zugriff XML & JSON 1
R Zugriff auf Inhalt eines Elements XML & JSON 2
O XML Zugriff auf Entity File XML & JSON 0
F Zugriff auf durch JAXB erzeugte Object-Struktur... XML & JSON 6
R eXist Datenbank --> Servlet-Zugriff Treiber? XML & JSON 6
B Probleme mit Zugriff auf eXist-Datenbank XML & JSON 9
P zugriff auf gewuenschte elemente klapp nicht. XML & JSON 3
J Zugriff auf Web Service über den Browser XML & JSON 12
A XML Attributte Zugriff XML & JSON 5
iman XML Attribute mit JAVA einlesen mit Spring Batch XML & JSON 0
L Transformer verschluckt Attribute bei der Ausgabe XML & JSON 3
W XML einlesen und Attribute auslesen XML & JSON 1
D Attribute aus XML Auslesen XML & JSON 5
R cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'. XML & JSON 4
C JAXB: XML-Elemente einlesen und als XML-Attribute ausgeben XML & JSON 7
F EMF, XSD to ECore mapping, Attribute vs. Element XML & JSON 2
A XML-Attribute vergleichen XML & JSON 4
Helgon MalformedByteSequenceException und null JDOM Attribute XML & JSON 5
G JAXB XML-Attribute feststellen XML & JSON 4
2 wie komme ich an die Attribute XML & JSON 3
B 2 Attribute in einer xsl XML & JSON 2
M Gegenseitig ausschließende Attribute definieren in XSD XML & JSON 7
C DOM: Attribute nicht in alphabetischer Reihenfolge schreiben XML & JSON 3
eQuest XML Jaxen Attribute auslesen XML & JSON 2
C Mit SAX Parser XML Attribute auswerten XML & JSON 3
H XML Attribute auslesen XML & JSON 5
S JAXB und viele verschachtelte Attribute XML & JSON 1
G xquery - nodes unterscheiden sich nur durch attribute :-( XML & JSON 4
L Objekt Serialisierung: Schreiben aller Attribute erzwingen XML & JSON 5
E EMF Modell um alle möglichen Attribute auszulesen XML & JSON 12

Ähnliche Java Themen

Neue Themen


Oben