' The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Public NotInheritable Class MainPage
    Inherits Page

    Private Sub TlacitkoTestXml_Click(sender As Object, e As RoutedEventArgs) Handles TlacitkoTestXml.Click
        'CVICENI 1: Otevreni XML dokumentu a zobrazeni jeho obsahu
        'v textovem poli.
        '  Tento kod nacita obsah XML dokumentu do objektu Studenti a zobrazuje
        '  jeho obsah v textovem poli, a to vcetne veskerych navesti.

        'TextovePoleVystup.Text = "Veškerý obsah XML dokumentu včetně návěští:" & _
        'vbCrLf & vbCrLf
        'Dim Studenti As XDocument = XDocument.Load("Assets/Studenti.xml")
        'TextovePoleVystup.Text &= Studenti.ToString

        'CVICENI 2: Zobrazeni vybranych zaznamu z XML dokumentu pomoci jazyka LINQ.
        '  V nasledujicim dotazu jazyka LINQ budou v textovem poli zobrazeny vsechny
        '  ty prvky, jejichz navesti (typ) je rovno PRIJMENI.
        '  Plati, ze je nutne dodrzovat velikost pismen!

        'TextovePoleVystup.Text = "Příjmení všech studentů zimního kurzu:" & _
        '    vbCrLf & vbCrLf
        'Dim Studenti As XDocument = XDocument.Load("Assets/Studenti.xml")
        'Dim dotaz = From osoba In Studenti.Descendants("PRIJMENI")
        '            Select osoba.Value

        'For Each polozka In dotaz
        '    TextovePoleVystup.Text &= polozka & vbCrLf
        'Next

        'CVICENI 3: Zobrazeni XML prvku, vnorenych do slozitejsi hierarchie XML.
        '  Tento priklad zobrazuje instruktora lyzovani, ktery by mel v lyzarske
        '  skole pracovat v zime roku 2015. Jeho jmeno je uvedeno v souboru Studenti.xml.

        TextovePoleVystup.Text = "Instruktoři školy pro výuku v zimě 2015: " & _
            vbCrLf & vbCrLf
        Dim Studenti As XDocument = XDocument.Load("Assets/Studenti.xml")
        TextovePoleVystup.Text = TextovePoleVystup.Text & _
            Studenti.Element("STUDENTI").Element("ZIMA2015").Element("INSTRUKTOR").Value

        'SAMPLE 4: Use LINQ to search creatively in an XML document.
        '  This query searches the SkiTeam2014.xml file for female skiers 
        '  between 16 and 17 (inclusive) that are in the XML document.

        'OutputTextBox.Text = "Female ski school students between 16 and 17" & vbCrLf & vbCrLf
        'Dim xdoc As XDocument = XDocument.Load("Assets/SkiTeam2014.xml")
        'Dim query = From skier In xdoc.Descendants("Skier")
        'Where (skier.Attribute("Gender").Value = "F") _
        'And (skier.Attribute("Age").Value >= 16) And (skier.Attribute("Age").Value <= 17)
        'Select FName = skier.Attribute("FirstName").Value,
        'LName = skier.Attribute("LastName").Value

        'For Each skier In query
        '    OutputTextBox.Text &= skier.FName & " " & skier.LName & vbCrLf
        'Next

        'SAMPLE 5: Modify an element in the in-memory copy of an XML Document.
        '  This code shows how to change the LASTNAME field in the first record in the XML file
        '  from Smith to George. The final line displays the name so that you can verify the change.

        'Dim xdoc As XDocument = XDocument.Load("Assets/Students.xml")
        'xdoc.Element("STUDENTS").Element("WINTER2014").Element("LASTNAME").SetValue("George")
        'OutputTextBox.Text = xdoc.Element("STUDENTS").Element("WINTER2014").Element("LASTNAME").Value

        'SAMPLE 6: Add to an XML Document by creating a new node.
        '  To create a new XML "node" and add it to the end of the LASTNAME section, do this:
        '  Load XML document into Students variable. Create a new XElement object to hold
        '  the new node, and assign the LASTNAME value "Lyon" to the node.
        '  Use Add method to add the new node to the end of the LASTNAME section.
        '  Display modified XML document in the text box (with tags) to verify change.

        'Dim Students As XDocument = XDocument.Load("Assets/Students.xml")
        'Dim xe As XElement = New XElement("LASTNAME", "Lyon")
        'Students.Element("STUDENTS").Element("WINTER2014").Add(xe)
        'OutputTextBox.Text = Students.ToString
    End Sub
End Class
