XML Document lesen

Elteide

Cadet 2nd Year
Registriert
Juni 2008
Beiträge
19
Hallo liebe Community,

hab schon wiedermal ein Problem. :) Mit einer XML Datei.
Code:
<test>
  <Event>
    <Datum>2008-7-27</Datum>
      <ActiveServiceSection>
       <ActiveService>10</ActiveService>
       <ActiveService>20</ActiveService>
       <ActiveService>30</ActiveService>
      </ActiveServiceSection>
  </Event>
    <Event>
    <Datum>2008-7-28</Datum>
      <ActiveServiceSection>
       <ActiveService>55</ActiveService>
       <ActiveService>44</ActiveService>
       <ActiveService>33</ActiveService>
       <ActiveService>4</ActiveService>
      </ActiveServiceSection>
  </Event>
  <Event>
    <Datum>2008-7-29</Datum>
      <ActiveServiceSection>
       <ActiveService>21</ActiveService>
       <ActiveService>22</ActiveService>
      </ActiveServiceSection>
  </Event>
  <path>C:\AmosHubMonitor.config</path>
</test>

soo nun die Herausvorderun. Wie kann ich die Heutigen Werte (nach Datum) in ActiveService auslesen??? Soweit mein Code:

PHP:
Imports System.Xml

Module Module1

    Sub Main()
        Dim today As String
        Dim date1 As New Date : date1 = Now
        today = (date1.Year & "-" & date1.Month & "-" & date1.Day)

        Dim xmldateiconf As New Xml.XmlDocument
        Dim xmllistconf As Xml.XmlNodeList
        Dim Anzahl2 As Integer
        Dim Zeilen2 As String : Zeilen2 = -1
        Dim b As New ArrayList
        Dim c1 As String
        Dim c As New ArrayList
        Dim Schleife1 As Integer
        Dim z2 As String : z2 = 0


        xmldateiconf.Load("c:/Hub_Monitor_config.exe.config")
        xmllistconf = xmldateiconf.GetElementsByTagName("Datum")
        Anzahl2 = xmllistconf.Count
        b.Add(Anzahl2.ToString)


        For Schleife1 = 0 To Anzahl2
            If Schleife1 = Anzahl2 Then





            End If

            If Schleife1 < Anzahl2 Then
                Zeilen2 = Zeilen2 + 1
                c1 = xmllistconf(Zeilen2).InnerText
                c.Add(c1.ToString)
            End If
        Next
    End Sub
End Module

Zum Heutigen Datum ist es kein Problem, aber wie springe ich jetzt zu ActiveService und lese dort die Werte aus?

Vielen Dank im Voraus für euere Antworten

LG Elteide
 
Hat "xmllistconf" ne Methode die GetElementsByTagName heißt ?
 
Ja... bei mir funktioniert es....
Wie schaffe ich es jetzt die ActiveService nummern vom aktuellen Datum auszulesen?
Oder sollte ich die XML-Datei irgendwie anders aufbauen um es einfacher zu gestalten? Ich
freuhe mich über jede Idee die ihr habt.

LG Elteide
 
Hey habs jetzt geschafft mich durchzuhangeln... Was mir noch fehlt ist wie kann ich nun die ActiveService nummern der reihe nach auslesen? Ich hoffe ihr könnt mir dabei helfen...

LG Elteide



PHP:
Imports System.Xml

Module Module1

    Sub Main()
        Dim today As String
        Dim date1 As New Date : date1 = Now
        today = (date1.Year & "-" & date1.Month & "-" & date1.Day)
        

        Dim xmldateiconf As New Xml.XmlDocument
        Dim xmllistconf As Xml.XmlNodeList
        Dim myxmlnode As Xml.XmlNode
        Dim Anzahl2 As Integer
        Dim anzahl3 As Integer
        Dim Z As Integer : Z = 0
        Dim c2 As String
        Dim c1 As New ArrayList
        Dim c3 As New ArrayList


        Dim i As Integer

        xmldateiconf.Load("c:/Hub_Monitor_config.exe.config")
        xmllistconf = xmldateiconf.GetElementsByTagName("Datum")
        Anzahl2 = xmllistconf.Count



        For i = 0 To Anzahl2
            If i < Anzahl2 Then
                c2 = xmllistconf(i).InnerText
                c1.Add(c2.ToString)
            End If
            If i = Anzahl2 Then
                Exit For
            End If
        Next


        For i = 0 To Anzahl2
            If c1(z) = today Then
                myxmlnode = xmllistconf(0).NextSibling             
                anzahl3 = myxmlnode.ChildNodes.Count

                                'xmllistconf(0).GetElementsByTagName("ActiveService")
                                'Das funktioniert nicht...

            End If
            If c1(z) < today Then
                z = z + 1
            End If
        Next    
    End Sub

End Module
 
Renn doch über alle ActiveService drüber und hau die in ein SortedDictionary
 
Zurück
Oben