XmlConvert.ToDateTime converts the String to a DateTime equivalent. : XmlConvert « XML « VB.Net






XmlConvert.ToDateTime converts the String to a DateTime equivalent.

 


Imports System
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim reader as XmlTextReader = new XmlTextReader("myData.xml")
    while (reader.Read())
       if (reader.NodeType=XmlNodeType.Element)
         select case reader.Name
           case "order":
             Dim orderDate as DateTime = XmlConvert.ToDateTime(reader.GetAttribute("date"))
             Console.WriteLine("order date: {0}", orderDate.ToString())
           case "price":
             Dim price as Double = XmlConvert.ToDouble(reader.ReadInnerXml())
             Console.WriteLine("price: {0}", price.ToString())
         end select
       end if
    end while

    reader.Close()  
  end sub
end class

   
  








Related examples in the same category

1.XmlConvert.DecodeName
2.XmlConvert.ToDateTimeOffset
3.XmlConvert.ToString converts the DateTime to a String.
4.XmlConvert.VerifyWhitespace
5.Encode and decode a local name
6.Returns valid XML characters