0

I need method like

public bool IsValid(string xmlText) {
 // validation xml
}

I can write code like:

public bool IsValid(string xmlText) {
  try {
    XmlReader reader = XmlReader.Create(new StringReader(xmlText), settings);
    while (reader.Read());
  }
  catch {
    return false;
  }
  return true;
}

But I want write code without thrown exception. How I can do it?

AndreyAkinshin
  • 18,603
  • 29
  • 96
  • 155

1 Answers1

1

Use Custom Validation. Pretty simple to implement.

Anatolii Gabuza
  • 6,184
  • 2
  • 36
  • 54