Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Navigation durch XML mittels XML-Parser

Empfohlene Antworten

Veröffentlicht

Guten Tag,

Also nach dem, nun endlich behobenen Problem aus meinem anderen Thema , habe ich nun ein kleines weiteres Problem.

Und zwar Navigieren wir ja in dem Skript aus dem anderen Thema durch eine XML-Datei mit Hilfe des XMLParsers... so nun ist da aber eine Stelle im XML-File zu der wir es nicht schaffen hinzunavigieren.

Hier mal der Aufbau dieser Stelle:


<item>

    <customfields>




    <customfield id="customfield_10055" key="bla">


       <customfieldname>BLABLABLO</customfieldname>


       <customfieldvalues>

          [COLOR="Red"]<customfieldvalue>BLUBBLUB</customfieldvalue>[/COLOR]

       </customfieldvalues>


    </customfield>





    <customfield id="customfield_103456" key="blu">


       <customfieldname>BLABLABLU</customfieldname>


       <customfieldvalues>

          [COLOR="Red"]<customfieldvalue>BLUBBLUBBLUB</customfieldvalue>[/COLOR]

       </customfieldvalues>


   </customfield>




   </customfields>

</item>

So... das ist das Schema des Problems welches in der XML-Datei ist...

Was wir wollen, also den wert der uns am ende ausgegeben werden soll ist der text im Bereich "customfieldvalue" (rot) ...

und wir wollen irgendwie mit hilfe der id in customfield dort hin navidieren, bekommen dies aber nicht so wirklich hin...

hoffe da kann uns jemand helfen..

vielen dank

hm irgendwie klappt das nich so recht...

kannst du mal n einfaches beispiel welches funktioniert draus machen?

z.b. einfach so mit println zum beispiel..

wär cool

Da ich mich bis jetzt nicht mir Groovy auseinander gesetzt habe hier mal der Java Code.


DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

Document doc = builder.parse("src/forum.xml");

XPath xpath = XPathFactory.newInstance().newXPath();

NodeList nodes = (NodeList) xpath.evaluate("//customfield[@id='customfield_10055']/customfieldvalues/customfieldvalue", doc, XPathConstants.NODESET);


for (int i = 0; i < nodes.getLength(); i++) 

{

    System.out.println(nodes.item(i).getTextContent()); 

}

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.