Is there more elegant syntax for reading/parsing Size and Point objects in an Xml document?
Source Xml Nodes:
<objSize>{Width=64, Height=64}</objSize>
<Location_X>20</Location_X>
<Location_Y>20</Location_Y>
Currently I use: For Size:
Dim sizeNode As String = objSize.InnerText
Dim sizeText() As String = sizeNode.Split(CChar("="))
Dim width As Integer = XmlConvert.ToInt32(sizeText(1).Split(CChar(","))(0))
Dim height As Integer = XmlConvert.ToInt32(sizeText(2).TrimEnd(CChar("}")))
Dim newSize as New Size(width, height)
For Point:
Dim newLocation As Point
newLocation = New Point(XmlConvert.ToInt32(objNode.InnerText), newLocation.Y)
newLocation = New Point(newLocation.X, XmlConvert.ToInt32(objNode.InnerText))
I have a nagging feeling like I am missing something? I have control over both the source nodes and the parsing code... So I am just being too lazy with my XmlNode creation? Regardless is there any benefit to using XmlConvert v.s. using integer.parse (or .tryparse)?