I have an XML format with following format
<Tag>
Value
</Tag>
This comes from an external datasource I cannot change.
When using XmlReader
the content has Linebreaks
and Whitepace
.
XmlReaderSettings xmlSettings = new XmlReaderSettings();
xmlSettings.Schemas = new System.Xml.Schema.XmlSchemaSet();
XmlReader schemaReader = XmlReader.Create(xsdStream);
xmlSettings.Schemas.Add("", schemaReader);
xmlSettings.ValidationType = ValidationType.Schema;
reader = XmlReader.Create(xmlFilename, xmlSettings);
// Parse the XML file.
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Tag":
string value = reader.ReadElementContentAsString();
Console.WriteLine(value);
break;
}
}
}
How can I avoid this?