473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to check wellformed xml in Web services

Hi,
I am having a webmethod in my web services that accept a xml as string parameter.

[WebMethod]
public bool GetValidXML(string xmlDocument)

Now i want to perform a check againt string xmlDocument that it is in well formed or not?

i used a XMLTextReader that accept input in stream format so to pass my string in xmltextreader i have already converted my string into stream. after it my pain area begin

i cant not use try catch block in web serverices so when i pass null string or <a> it return error but i need only true or false value based on my string if it is in well formed then true otherwise false

my code is


[WebMethod]
public bool GetValidXML(string xmlDocument)
{

ASCIIEncoding myEncoder = new ASCIIEncoding();
byte[] bytes = myEncoder.GetBytes(xmlDocument);
MemoryStream ms = new MemoryStream(bytes);


XmlTextReader reader = new XmlTextReader((Stream)ms);
reader.XmlResolver = null; // ignore the DTD
reader.WhitespaceHandling = WhitespaceHandling.None;

if (reader.Read())
{

//XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.LoadXml(xmlDocument);
//if (xmlDoc.InnerText.ToString().Length > 0)
//{
return true;
}
else
{
return false;
}
}
Apr 27 '07 #1
0 903

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jonathan W. Zaleski | last post by:
I was wondering if such a plugin existed outside the Office Bundle, that would preform a spell-check of an indicated field within a HTML Page.
2
by: Tom S | last post by:
Is there a way (without a schema or dtd) to check that my XML (currently held in a string variable) is wellformed? I've looked on google and in the help files and couldn't find anything about...
2
by: Chris Podmore | last post by:
I don't know if this is the correct newsgroup but I couldn't find one for Windows Services Is it possible to check that a Windows Service is still running from another machine The idea being a...
12
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
3
by: H8ComputersSomeDays | last post by:
I want to have my program automatically check for a new version when it is run. My app is in VB.NET (VS 2003). Updates are posted on my website and I would like the app to go to the site and check...
11
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. Is there a way to programmatically check for .NET Framework versions installed on the computer? -- Michael Bragg,...
10
by: Dieter Pelz | last post by:
Hallo, what is the best way to check the installation of mfc80 and vcrt sidebyside assemblies? Best Regards, Dieter Pelz
3
by: nRk | last post by:
Hi, Is there any way to check the availability of a web service without including any extra web method? Thank & regards nRk
0
by: Gina G | last post by:
I have to log Regular services that occur as required but not more than 31 days later than the previous. Additionally a major service must occur within 6 months of the previous major service. A...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.