Re: How to check if a string is an XML before calling LoadXML(str)



I am new to C# so I might be asking some silly questions. The issue is that
if the str is not XML then I would like to do something else instead of being
kicked out by exception. Thanks!

"Jon Skeet [C# MVP]" wrote:

> cloudx <cloudx@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > hi there, in VB LoadXML(str) returns true or false so that you can do
> > different coding when the str is XML or not, but in C# LoadXML doesn't have
> > return but only throw exception if str is not XML document. How would I do if
> > I want to do my own code if str is not an XML? thanks!
>
> Anything wrong with catching the exception? It seems the simplest way
> to me.
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>
.



Relevant Pages

  • Re: How to check if a string is an XML before calling LoadXML(str)
    ... Catching an Exception is not necessarily being "kicked out." ... // it wasn't XML if we get here, ... >>> different coding when the str is XML or not, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to check if a string is an XML before calling LoadXML(str)?
    ... > different coding when the str is XML or not, but in C# LoadXML doesn't have ... > return but only throw exception if str is not XML document. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: multiple siblings, using tDOM to generate XML
    ... A simple way to generate XML is the following: ... proc map { ... return [string map $mapTEXT2XML $str] ... set doc ...
    (comp.lang.tcl)
  • Re: REXML memory consumption
    ... I created a test that consisted of feeding 10 xml ... I would think that memory usage ... Is there something wrong with my understanding of Ruby or does REXML ... str << line ...
    (comp.lang.ruby)
  • Re: REXML memory consumption
    ... I would think that memory usage ... Is there something wrong with my understanding of Ruby or does REXML ... str << line ... No need to read the whole file into a large string before it is parsed as XML. ...
    (comp.lang.ruby)