XML : How do I get the attribute of an XmlElement as a double without creating a redundant class?

I have the following snippet of code:

  <XmlElement("point")> _                  Public Property points() As List(Of Double)                      Get                          Return myPoints                      End Get                      Set(value As List(Of Double))                          myPoints = value                      End Set                  End Property    

In reference to the following section of my XML document:

  <upperLimit color="red">                  <point y="12"/>                  <point y="13"/>                  <point y="14"/>                  <point y="15"/>                  <point y="16"/>              </upperLimit>    

I am trying to tell my VB program that I want it to create a list of doubles from the list of "points" in my XML document. What I can't understand is how I can tell it to look at the XmlElement point and not take it's innerText but rather the XmlAttribute y

So something like this (i know this is wrong)

  <XmlElement("point").XmlAttribute("y")> _ <-- Notice this line!!                  Public Property points() As List(Of Double)                      Get                          Return myPoints                      End Get                      Set(value As List(Of Double))                          myPoints = value                      End Set                  End Property    

The only other alternative I see would be to create yet ANOTHER class to attribute the value to. I also can't even think of what to search on google to find an answer to this... Thanks!

No comments:

Post a Comment