InCorrect XML formats are not Rejecting while Validating XML in C# -
i validating string weathere has valid xml format? while have added incorrect xml format
incorrect formats need rejected accepting
string parameters="abc>" string parameters="abc"
coorect format need accepted rejected
string parameters=<paramnumber aaa="120901" />
is rejecting
my code :
public bool isvalidxml(string value) { try { // check have value if (string.isnullorempty(value) == false) { // try load value document xmldocument xmldoc = new xmldocument(); xmldoc.loadxml("<root>" + parameters+ "</root>"); // if managed no exception valid xml! return true; } else { // blank value not valid xml return false; } } catch (system.xml.xmlexception) { return false; } }
please let me know how can handle these properly.
regards,
channa
i think correct syntax 3rd 1 should be
string parameters = "<paramnumber aaa=\"120901\" />";
but you're looking else guess.
Comments
Post a Comment