Pasing XML Document on CE

Hi,

I've a XML Document with a structur like this:
<?xml version="1.0" encoding="utf-8"?>
<screens>
  <test1 name="Kalender" bgimage="Menu2">
    <control id="1" event="My1_Click" xy="1" name="Raume" active="Pic2o" type="1" />
    <control id="2" event="My2_Click" xy="2" name="Kalender" active="Pic1o" type="1" />
    <control id="3" event="My3_Click" xy="3" name="Einnstellungen" active="Pic3o" type="1" />
  </test1>
  <test2 name="Raeume" bgimage="Menu">
    <control id="1" event="My1_Click" xy="1" name="Raume" active="Pic1o" type="1"/>
    <control id="2" event="My2_Click" xy="2" name="Kalender" active="Pic2o" type="1" />
    <control id="3" event="My3_Click" xy="3" name="Einnstellungen" active="Pic3o" type="1" />
  </test2>
  <test name="Test" bgimage="Menu">
    <control id="1" xy="1" name="Raume" type="2" width="50" height="100"/>
    <control id="2" xy="2" name="Kalender" type="3" width="250" height="20"/>
    <control xy="3" name="Einnstellungen" type="4" width="100" height="20"/>
    <control id="4" event="My1_Click" xy="2" name="Kalender" active="Pic2o" type="1" />
  </test>
</screens>

To access the nodes at the moment I use:
private static XmlDocument screens = new XmlDocument();
screens.Load(Globals.inipath + "screens.xml");
// Access node I need
XmlNodeList nodes = screens.SelectNodes("screens/test/control");
// Get Attributes
foreach (XmlNode node in nodes)
int ty = Convert.ToInt32(node.Attributes["type"].Value);
                switch (ty)
                {
                case 1:
                    ta = node.Attributes["event"].Value;
                    ...
                    break;
                 case 2:
                    wi = node.Attributes["width"].Value;
                    ...
                    break;
            {
}

Yes it works, but I've ever depending from the ID to select what Attributes I've to read.

Is there a way to access any Attribute included by a loop like XMLTextReader (MoveToNextAttribute) can do?
For sure I could complete change to XMLTextReader but I think than I've to miss SelectNodes.

Is it possbile to combinate both?
I'm developing with the CF 2.0 and can't upgrade it.

Thanks,

Andre
andre72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BigRatCommented:
>>Yes it works, but I've ever depending from the ID to select what Attributes I've to read

I don't quite understand that sentence. You can explain ine German if you wish.

Secondly you select all control nodes and select the type attribute, then select on its value.

Node.Attributes is a NamedNodeMap which is a combination of an iterator (with item, nextNode and reset) and getQualifiedItem and getNamedItem methods. So if you can explain what you want to do exactly, it will be possible to do it.
0
andre72Author Commented:
Ok, Deutsch ist leichter ...
Also, jeder Control Eintrag hat ja eine unterschiedliche Anzahl an Attributen, diese heissen nun auch wiederum anders (mal event="", andere haben width="" usw.)

Mit dem XMLTextReader könnte ich das ja in einer Schleife durchlkaufen, müßte aber ebenso vorher meinen Knoten suchen (while (reader.Read()) während ich mit SelectNodes ja direkt entsprechenden Knoten anspreche (obwohl das intern wohl auch nichts anderes machen wird, als diesen in einer Schleife zu suchen).
Also was ich suche ist eigentlich folgend Möglichkeit:
nodes = screens.SelectNodes("screens/" + room + "/control");
foreach (XmlNode node in nodes)
            {
                     foreach(attribute in irgendwas)
                     {
                     }
             }
0
BigRatCommented:
Node.attributes returns a NamedNodeMap which supports an iterator. The iterator will return nodes (of type attribute). The NamedNodeMap was introduced so that one could directly access the attribute nodes without have to get each individual node. So it goes :-

      foreach (XMLNode attNode in Node.Attributes)  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andre72Author Commented:
Bis auf Deinen Tippfehler perfekt - mit foreach (XmlAttribute attNode in node.Attributes) geht es. Vielen Dank
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.