0

I've a xml file with partial whitespace;

<file>
  <document>
     <data>1</data>
     <data>2</data>
     <data>3</data>
  </document><document>      //whitespace missing
     <data>1</data>
     <data>2</data>
     <data>3</data>
  </document>
</file>

When i use XmlTextReader to read the xml file and use the following code to find an element;

XmlTextReader reader = new XmlTextReader(xmlFile);

while (reader.Read())
 {
  {
   if (reader.NodeType == XmlNodeType.Element)

it doesn't find the second element <document> (caused by the reader position) How can i change my code to read all elements. As a workaround i now write a temporary file replacing >< with >\n<

John Doe
  • 9,843
  • 13
  • 42
  • 73

1 Answers1

0

If no-one else is answering: My guess is you're reading the xml inside the loop, maybe with ReadOuterXml(). Whitespace between elements shouldn't matter.

AndrewR
  • 162
  • 1
  • 8