xml validation problem in .net

Last post 04-07-2006 12:25 PM by lax4u. 6 replies.

Sort Posts:

  • xml validation problem in .net

    05-12-2005, 5:45 PM
    • Member
      669 point Member
    • test2003
    • Member since 01-03-2003, 8:46 PM
    • Posts 144
    I am using XSD schema to validate xml in .net program. It is woking correctly. Following is the event handler to handle the validation:
    <code>
            public void ValidationHandler(object sender, ValidationEventArgs e)
           {
            ....
           }
    </code>

    Two question:
    1. The e.Message is something like this: "The 'Title' element has an invalid value according to its data type. An error occurred at , (1, 572)." What is (1, 572) mean?
    2. How can I get the content of the 'Title" which has an invalid value? It will be very easy to find out why it is invalid if we can log the actual content of the "Title" element with the error message together.

    Thanks


  • Re: xml validation problem in .net

    05-12-2005, 11:13 PM
    • Contributor
      4,280 point Contributor
    • tomasr
    • Member since 04-28-2003, 11:18 AM
    • Colombia
    • Posts 852
    1. The (1,572) means the error was detected on line 1, character 572
    2. You'd need to actually access the XML document you're validating and get the value out of it....

    Tomas Restrepo [MVP]
    tomasr@mvps.org
  • Re: xml validation problem in .net

    05-12-2005, 11:25 PM
    • Member
      669 point Member
    • test2003
    • Member since 01-03-2003, 8:46 PM
    • Posts 144
    1. kind of strange, since they are a lot of errors in the SAME xml and the pairs are all start with 1, such as (1, 572), another one (1, 945), (1, 3743) etc... and the first line of xml is very short.

    2. Yes, the program loaded both schema and XML. how to find out the invalid value? I mean in the program. (not manually open xml and check it).

    Thanks.

  • Re: xml validation problem in .net

    05-13-2005, 11:41 AM
    • Contributor
      4,280 point Contributor
    • tomasr
    • Member since 04-28-2003, 11:18 AM
    • Colombia
    • Posts 852
    Regarding 1, how are you loading the XML document? perhaps that has something to do with it.

    As for the second, well, that's what I ment: use the XML you have loaded to get the values, just use the DOM to extract them.

    Tomas Restrepo [MVP]
    tomasr@mvps.org
  • Re: xml validation problem in .net

    05-13-2005, 12:01 PM
    • Member
      669 point Member
    • test2003
    • Member since 01-03-2003, 8:46 PM
    • Posts 144
    the xml are generated in the program and stored in a XmlDocument object. so the problem right now is how do I extract the value from XmlDocument object using the position like (1, 572)?

    Thanks for the reply.

  • Re: xml validation problem in .net

    05-19-2005, 3:41 PM
    • Member
      669 point Member
    • test2003
    • Member since 01-03-2003, 8:46 PM
    • Posts 144
    still haven't figure out. anyone can help? thanks.
  • Re: xml validation problem in .net

    04-07-2006, 12:25 PM
    • Participant
      1,576 point Participant
    • lax4u
    • Member since 05-28-2004, 10:45 AM
    • Posts 857

    Check XmlValidatingReader.Value property .The value returned depends on the NodeType of the node. The following table lists node types that have a value to return. All other node types return String.Empty.

    http://msdn2.microsoft.com/en-us/library/system.xml.xmlvalidatingreader.value(VS.80).aspx

    If the NodeType is XmlNodeType.Element use XmlValidatingReader.ReadString() method .I', m not sure about ReadString() method but you can try it.for me its working.

Page 1 of 1 (7 items)