Click here to Skip to main content
15,889,403 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do you check to see if a web service is running or not? Pin
Dave Kreskowiak1-Oct-09 16:23
mveDave Kreskowiak1-Oct-09 16:23 
GeneralRe: How do you check to see if a web service is running or not? Pin
PIEBALDconsult2-Oct-09 3:42
mvePIEBALDconsult2-Oct-09 3:42 
QuestionException while creating table in azure. Pin
VasntKrish1-Oct-09 9:23
VasntKrish1-Oct-09 9:23 
QuestionXML, XSD VALIDATION Pin
waqasm1-Oct-09 8:16
waqasm1-Oct-09 8:16 
AnswerRe: XML, XSD VALIDATION Pin
Henry Minute1-Oct-09 10:50
Henry Minute1-Oct-09 10:50 
GeneralRe: XML, XSD VALIDATION Pin
waqasm1-Oct-09 11:09
waqasm1-Oct-09 11:09 
GeneralRe: XML, XSD VALIDATION Pin
Henry Minute1-Oct-09 11:48
Henry Minute1-Oct-09 11:48 
GeneralRe: XML, XSD VALIDATION Pin
waqasm2-Oct-09 3:56
waqasm2-Oct-09 3:56 
Hey,
I fixed what you had asked me to fix. But i am getting this error in my output box. "Exception Illegal characters in path."

using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Xml;
using System.Xml.Schema;

//void ValidateXML(string strXML,string strXSD,string strXSDNS)
namespace ValidateXML
{
      
    public partial class Form1 : Form
    
      {
         
        public Form1()
        {
        InitializeComponent();
        }
                
       string strXML; //- In put XML file
       string strXSD; //- In put XSD file
       string strXSDNS;

        void ValidateXML(string strXML, string strXSD, string strXSDNS)
        {
            
            //Create a XmlValidatingReader, XmlSchemaCollection and ValidationEventHandler objects to be used to validate the XML against an XSD file
           
            
            XmlValidatingReader reader = null;
            //XmlSchemaCollection myschema = new XmlSchemaCollection();
            XmlSchemaSet myschema = new XmlSchemaSet();
            ValidationEventHandler eventHandler = new ValidationEventHandler(ShowCompileErrors);
                        
            try
            {
                
                                                  
                XmlDocument doc = new XmlDocument();
                doc.Load(strXML);
                string xmlFrag = doc.InnerXml;
                           
                //Create an XmlParserContext object for use with the XMLValidatingReader:
                //String xmlFrag = "<author  xmlns='urn:bookstore-schema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
                // "<first-name>Herman</first-name>" +
                // "<last-name>Melville</last-name>" +
                //"</author>";
                //Create the XmlParserContext.
              
                XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);

                //Implement the reader. 
                reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);

                // Add the relevant schema files (.XSD) to the name space we are checking
                //against and repeat until all the schema's have an associated XSD file with them.

                //Add the schema.
                //myschema.Add(strXSD, strXSD);
                myschema.Add(strXSD, "C:/Umar/C:/Umar/H1N1_Schema.xsd");
                //Set the schema type and add the schema to the reader.
                reader.ValidationType = ValidationType.Schema;
                reader.Schemas.Add(myschema);
                // Read in the XML Data:
                
                while (reader.Read())
                {

                }
               
              //If there is no exception, display "Completed Validating" or return a value indicating success

                output.Text = "Completed validating " + strXML;
                
            }
            //Watch out for exceptions within the XML file and display them appropriately to the user:

            catch (XmlException XmlExp)
            {
                output.Text = "XMLException " + XmlExp.Message;
            }

           //XMLSchemaExceptions are thrown when the XML document does not match the schema provided.

            catch (XmlSchemaException XmlSchExp)
            {
                output.Text = "XMLSchemaException " + XmlSchExp.Message;
            }

            //Catch all other exceptions and report them to the user:

            catch (Exception GenExp)
           {
                output.Text = "Exception " + GenExp.Message;
           }
      }
          
       private void button1_Click(object sender, EventArgs e)
        {
            String a = null;
            String b = null; 
            if (txt_inputXML.Text == String.Empty)
            {
                output.Text = ("Warning: Upload a XML file");
            }
            else if (txt_inputXSD.Text == String.Empty)
            {
                output.Text = ("Warning: Upload a XSD File");
            }
            
            else
            {
                output.Text = "yoo";
               ValidateXML(strXML, strXSD, "urn:bookstore-schema");
               /// ValidateXML(strXML, strXSD, "C:/Umar/H1N1_Schema.xsd");
               
            }
        }

     private void button2_Click(object sender, EventArgs e)
        {
            //outputtext.Text = "";
            // Create an OpenFileDialog object.
            OpenFileDialog openFile1 = new OpenFileDialog();
            // Initialize the OpenFileDialog to look for text files.
            openFile1.Filter = "(*.xml)|*.xml";

          if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txt_inputXML.Text = openFile1.FileName;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //outputtext.Text = "";
            // Create an OpenFileDialog object.
            OpenFileDialog openFile1 = new OpenFileDialog();

            // Initialize the OpenFileDialog to look for text files.
            openFile1.Filter = "(*.xsd)|*.xsd";

            if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)

                txt_inputXSD.Text = openFile1.FileName;
        }    
    }
}


ps. I was told that this website has tons of experienced programmers?? Why is there only one person helping me outConfused | :confused: Confused | :confused:
GeneralRe: XML, XSD VALIDATION Pin
Henry Minute2-Oct-09 5:29
Henry Minute2-Oct-09 5:29 
GeneralRe: XML, XSD VALIDATION Pin
waqasm7-Oct-09 6:14
waqasm7-Oct-09 6:14 
QuestionSqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 6:22
hande541-Oct-09 6:22 
AnswerRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 7:07
professionalMd. Marufuzzaman1-Oct-09 7:07 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 7:57
hande541-Oct-09 7:57 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 8:29
professionalMd. Marufuzzaman1-Oct-09 8:29 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 8:50
hande541-Oct-09 8:50 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Abhishek Sur1-Oct-09 10:31
professionalAbhishek Sur1-Oct-09 10:31 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
hande541-Oct-09 10:33
hande541-Oct-09 10:33 
GeneralRe: SqlServerCeException "There was an error parsing the query" help .... Pin
Md. Marufuzzaman1-Oct-09 20:15
professionalMd. Marufuzzaman1-Oct-09 20:15 
Questionsocket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 5:49
TimWallace1-Oct-09 5:49 
AnswerRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 6:22
sitebuilderLuc Pattyn1-Oct-09 6:22 
GeneralRe: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 6:56
TimWallace1-Oct-09 6:56 
GeneralRe: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 7:09
sitebuilderLuc Pattyn1-Oct-09 7:09 
General[SOLVED] Re: socket problem: works in visual studio, not as release Pin
TimWallace1-Oct-09 8:34
TimWallace1-Oct-09 8:34 
GeneralRe: [SOLVED] Re: socket problem: works in visual studio, not as release Pin
Luc Pattyn1-Oct-09 8:41
sitebuilderLuc Pattyn1-Oct-09 8:41 
QuestionMethod not calculating properly‏ Pin
Marcus Farrugia1-Oct-09 5:09
Marcus Farrugia1-Oct-09 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.