Chris Johnson

Chris Johnson

  • NA
  • 67
  • 32.3k

c# Reading XML nodes with spaces.

Apr 7 2016 8:15 AM
Hello all. This will be easy for someone. I am attempting to write a little program to read incoming reports from a customer.
while (reader.Read())
                            {
                                switch (reader.NodeType)
                                {
                                    case XmlNodeType.Element: // The node is an element.
                                        settings.IgnoreWhitespace = true;

                                        if (reader.Name == "vShipperNumber Text")
                                        {
                                            MessageBox.Show(reader.Name + " " + reader.Value);
                                        }
                                        break;
                                }
                            }

and a small piece of  the XML looks like this.
 
-<Row2>
<vShipperNumber Text="71370001"/>
</Row2>
 
So I get back vShipperNumber from the code because of the space and never get the value "71370001". Could someone please tell me what I am doing wrong? Please be aware I have never worked with XML before and I really have not yet understood the structure.
 
 
 

Answers (2)