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.

Liste in XML auslesen

Empfohlene Antworten

Hallo,

ich hab folgendes Problem:

Folgende Werte sollen aus einer XML Datei mit DOM ausgelesen werden:

FOLDER NAME, LOC, IDX

Die XML Datei hat folgendes Format:

<?xml version="1.0" standalone="yes" ?>

<LIST>

<VERSION_INFO>

<NR>4.07</NR>

</VERSION_INFO>

<FOLDER_LIST>

< FOLDER NAME ="TEST1" LOC="C:\tmp\test1" TYPE="O" IDX="1" />

< FOLDER NAME ="TEST2" LOC="C:\tmp\test2" TYPE="O" IDX="2" />

< FOLDER NAME ="TEST3" LOC="C:\tmp\test3" TYPE="O" IDX="3" />

</FOLDER_LIST>

</LIST>

Mit

XmlNodeList homeNodeList = xmlDoc.GetElementsByTagName("FOLDER_LIST");

XmlAttribute xmlAttr = homeNodeList[0].Attributes["FOLDER NAME"];

if (xmlAttr != null)

Console.WriteLine(xmlAttr.InnerText);

XmlNode xmlNode = homeNodeList[0].SelectSingleNode("LOC");

if (xmlNode != null)

Console.WriteLine(xmlNode.InnerText);

kriege ich keine Ergebnisse.

Danke für eure Hilfe.

Mal allgemein zu xml, also ein Node beginnt mit <NODE NAME

und endet mit /> bzw mit </NODE NAME>.

Also <VERSION_INFO> ist ein node und hat <NR> als child node.

<NR> wiederrum hat 4.07 als value.

<FOLDER_LIST> ist auch ein node, und hat <FOLDER NAME> als ChildNodes, wobei NAME, LOC etc Atribute der node sind.

Das ist richtig, hab irgendwie nicht richtig hingeschaut...

:) Danke das war der Fehler, nicht FOLDER NAME ist ein Attribut sonder FOLDER ein Knoten und der Rest die Attribute. Jetzt läufst. :D

Hier noch die Richtige Lösung :

XmlNodeList homeNodeList = xmlDoc.GetElementsByTagName("FOLDER");

XmlAttribute xmlAttr1 = homeNodeList[0].Attributes["NAME"];

if (xmlAttr1 != null)

Console.WriteLine(xmlAttr1.InnerText);

XmlAttribute xmlAttr2 = homeNodeList[1].Attributes["NAME"];

if (xmlAttr2 != null)

Console.WriteLine(xmlAttr2.InnerText);

.....

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.