jeudi 24 mars 2016

CreateNewCheckBox with Text from XML

I'm kinda stuck with reading the value of a xml-file. The XML looks like:

<?xml version="1.0" encoding="utf-16"?>
<spfFiles>
  <file>200_006 xxxxxxx</file>
  <file>200_010 xxxxxxx</file>
  <file>200_022 xxxxxxx</file>
  <file>200_023 xxxxxxx</file>
  <file>200_024 xxxxxxx</file>
  <file>200_031 xxxxxxx</file>
  <file>200_041 xxxxxxx</file>
</spfFiles>

What I'm trying to do is that I want to creat a new Checkbox for each file.

 XmlTextReader xReader = new XmlTextReader("spfFiles_simW.xml");
            while (xReader.Read())
            {
                switch (xReader.NodeType)
                {
                    case XmlNodeType.Text: //Display the text in each element.
                        pnlSPFLIST.Controls.Add(CreateNewCheckBox(xReader.Value));
                        break;
                }
            }

The creation of each new element works fine. But I've got trouble with the file names. Each Checkbox only gets the part before the space as a name. For example "200_006". My xmlReader somehow seems to cut the rest of.

Does anyone know where I've gone wrong?




Aucun commentaire:

Enregistrer un commentaire