Given this XML snippet:
...
<InSide:setHierarchyUpdates>
<automaticUpdateInterval>5</automaticUpdateInterval>
<shouldRunAutomaticUpdates>true<shouldRunAutomaticUpdates>
</InSide:setHierarchyUpdates>
...
I am attempting to serialize this object:
Imports System.Xml.Serialization
<XmlRoot(ElementName:="setHierarchyUpdates", namespace:="InSide")> _
Public Class HierarchyUpdate
<XmlElement(ElementName:="shouldRunAutomaticUpdates")> _
Public shouldRunAutomaticUpdates As Boolean
<XmlElement(ElementName:="automaticUpdateInterval")> _
Public automaticUpdateInterval As Integer
End Class
Like this:
Dim hierarchyUpdater As New HierarchyUpdate
Dim x As New XmlSerializer(hierarchyUpdater.GetType)
Dim objReader As Xml.XmlNodeReader = New Xml.XmlNodeReader(myXMLNode)
hierarchyUpdater = x.Deserialize(objReader)
However, the object, after deserialization, has values of false and zero. If I switch the objReader to a streamreader and read this in as a file, with none of its parents and no namespaces, it works:
<setHierarchyUpdates>
<automaticUpdateInterval>5</automaticUpdateInterval>
<shouldRunAutomaticUpdates>true<shouldRunAutomaticUpdates>
</setHierarchyUpdates>
What am I doing wrong? Should I use something other than XMLRoot in the class definition, because, as an XML node, it's not really the root? If so, what? Why are no errors returned when this fails?