Hello,
I have and xml file, like this:
<MyXMLFile>
<SerialNumber>111</SerialNumber>
<Name>MyName</Name>
<Size X="10" Y="12" />
</MyXMLFile>
The user who creates the XML data file, can change the order of the elements.
For example, "size" element can be before "name" element.
I have to read the whole data of this file.
As far as I know, XMLReader can't go back from it's position.
So one solution I thought about, is to create an xml reader and destroy it, again and again.
For example:
XmlReader xmlReader = XmlReader.Create(strXMLFileName);
xmlReader.ReadToFollowing(XMLNODE_Size);
int sizeX = Convert.ToInt32(xmlReader.GetAttribute("X"));
int sizeY= Convert.ToInt32(xmlReader.GetAttribute("Y"));
xmlReader.Close();
xmlReader = XmlReader.Create(strXMLFileName);
xmlReader.ReadToFollowing(XMLNODE_NAME);
xmlReader.ReadStartElement();
string name = xmlReader.ReadString();
xmlReader.ReadEndElement();
xmlReader.Close();
Is there a better way to do it, instead of close and reopen the xmlReader?
(I want also to read the attibutes where there are.)
Thanks