How to read this XML element? RRS feed

  • Question

  • User-1668014665 posted
    <docs frequency="daily">
            <dataset_name>Exchange Rates</dataset_name>
            <series_name>Daily – Australian dollar – Euro – Spot – Average</series_name>
                Dim nPeriodType As String = "None"
                Dim dt1 As New DataTable
                Dim ds1 As New DataSet
                Dim xml1 As XmlNode = JsonConvert.DeserializeXmlNode("{records:{record:" & History1 & "}}")
                Dim xmldoc1 As XmlDocument = New XmlDocument()
                xmlReader1 = New XmlNodeReader(xml1)
                If ds1.Tables("docs") IsNot Nothing Then
                    dt1 = ds1.Tables("docs")
                    If dt1.Rows.Count = 0 Then
                        res = "Error1: No records in XML source file."
                        Return "DataID " & DataSubID.ToString & ", " & Symbol & ", " & res
                    End If
                    Throw New Exception(Symbol & ", DBNomics Server Error(Docs) not found.")
                End If

    QUESTION : How can I read the contents of  attribute or element frequency in the first line <docs frequency="daily">??

    Out put wanted is 'Daily'.

    Using dt1 DataTable or other means?

    Any ideas?

    Sunday, August 9, 2020 9:54 PM


  • User-943250815 posted

    Considering you have XML as String

    Dim myXMLStr as string ' store xml string
    Dim myXML As New System.Xml.XmlDocument
    Dim myAttrVal as string = myXML.DocumentElement.Attributes("frequency").Value

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 10, 2020 1:26 PM