473,770 Members | 5,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xml Validation Error -> Automatically entered extra character

26 New Member
Hi there,
Hi Everybody, I am facing one problem to validate the xml file. first i load the xml file through XmlDocumentType Class. Before load the Xml file i add the code xmlresolver = null for not validating DTD. Then i get one particular node through getElementBytag name method. After find out the node i have add the attribute fot the node. then i save the xml file in particular path through xmldocumenttype .save() method. After i open the xml file the extra charater that is [] added at end of the DTD. After that i check the xml file through some other check, it throwns a error on special characte [] is added in end of dtd. i dont know when was the special character [] is added in dtd.
i am using C#.Net 2005. All process are done through XMLDocument class.
Please give me the solution.

Thanks In Advance,
Sekar.M
Apr 11 '07 #1
9 2592
dorinbogdan
839 Recognized Expert Contributor
Please post your code or a part of it that can be tested.
Thanks,
Dorin.
Apr 11 '07 #2
dorinbogdan
839 Recognized Expert Contributor
Oh, and post also the XML file.
Apr 11 '07 #3
sekarm
26 New Member
Dear Dorin,
Thank you for your quick reply. please find the xml file and code i attached.

The Xml File is
The file name is sample.xml

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE note SYSTEM "note.dtd">
  3. <ZooRoot>
  4.   <ZooTable Name="Crazy Zoo" Address="32 Turtle Lane" City="Austin" State="TX" Zip="12345">
  5.     <Classification Type="Reptiles" />
  6.     <Classification Type="Birds" />
  7.     <Classification Type="Primates" />
  8.   </ZooTable>
  9.   <ZooTable Name="Chicago Zoo" Address="23 Zebra Ave" City="Chicago" State="IL">
  10.     <Classification Type="Fish" />
  11.     <Classification Type="Mammals" />
  12.     <Classification Type="Primates" />
  13.   </ZooTable>
  14.   <ZooTable Name="Hungry Zoo" Address="45 Lion st" City="Miami" State="FL" Zip="33122">
  15.     <Classification Type="Arachnids" />
  16.     <Classification Type="Rodents" />
  17.   </ZooTable>
  18. </ZooRoot>
I have modified the above xml file through below this code,

Expand|Select|Wrap|Line Numbers
  1. using System.xml;
  2. XmlDocument Doc = new XmlDocument();
  3.             Doc.XmlResolver = null;
  4.             Doc.Load(@"E:\sample.xml");
  5.             XmlNodeList RootNode = Doc.GetElementsByTagName("Classification");
  6.             foreach (XmlNode filesnode in RootNode)
  7.             {
  8.                 //.ChildNodes[0].RemoveAll();
  9.                 filesnode.RemoveAll();
  10.  
  11.                 XmlNode createnode = Doc.CreateElement("Animal");
  12.                 XmlAttribute attr = Doc.CreateAttribute("AnimalName");
  13.                 attr.Value = "Lion";
  14.                 createnode.Attributes.SetNamedItem(attr);
  15.                 // Creat Attribute For New Node
  16.                 filesnode.AppendChild(createnode);
  17.             }
  18.             Doc.Save(@"E:\sample.xml");
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE note SYSTEM "note.dtd"[]> 
  3.         
  4.                 note it []
  5.  
  6. <ZooRoot>
  7.   <ZooTable Name="Crazy Zoo" Address="32 Turtle Lane" City="Austin" State="TX" Zip="12345">
  8.     <Classification>
  9.       <Animal AnimalName="Lion" />
  10.     </Classification>
  11.     <Classification>
  12.       <Animal AnimalName="Lion" />
  13.     </Classification>
  14.     <Classification>
  15.       <Animal AnimalName="Lion" />
  16.     </Classification>
  17.   </ZooTable>
  18.   <ZooTable Name="Chicago Zoo" Address="23 Zebra Ave" City="Chicago" State="IL">
  19.     <Classification>
  20.       <Animal AnimalName="Lion" />
  21.     </Classification>
  22.     <Classification>
  23.       <Animal AnimalName="Lion" />
  24.     </Classification>
  25.     <Classification>
  26.       <Animal AnimalName="Lion" />
  27.     </Classification>
  28.   </ZooTable>
  29.   <ZooTable Name="Hungry Zoo" Address="45 Lion st" City="Miami" State="FL" Zip="33122">
  30.     <Classification>
  31.       <Animal AnimalName="Lion" />
  32.     </Classification>
  33.     <Classification>
  34.       <Animal AnimalName="Lion" />
  35.     </Classification>
  36.   </ZooTable>
  37. </ZooRoot>
its correct, but added the extra character in end of DTD that is [], i have highlighted in above code.
thats the problem, i dont know how is that []bracket added in dtd.
so give me the solution. if you give the solution its very usefull for me.

Thanks In advance,
Sekar.M
Apr 11 '07 #4
dorinbogdan
839 Recognized Expert Contributor
Do you have the note.dtd file too?
Apr 11 '07 #5
sekarm
26 New Member
Its not necessary Dorin. i have given the code
Expand|Select|Wrap|Line Numbers
  1. doc.xmlresolver = null;
its does not check with any external resources, that is DTD you mention note.dtd.
you given that above code before document load function, the xmldocument does not care about that note.dtd. Again i tell you need not bother about this. just copy above codes and execute. if you comment the line
Expand|Select|Wrap|Line Numbers
  1. doc.xmlresolver=null;
its thrown the error. so i have use that code..
just execute the code, then copy the content in one txt file,then give the name
sample.xml
and give the location. then execute..
Please let me know if you have any concern.
Apr 11 '07 #6
Motoma
3,237 Recognized Expert Specialist
What Validator are you using? What is the exact message you are getting?
Apr 11 '07 #7
Motoma
3,237 Recognized Expert Specialist
Take a look at http://www.xml.com/lpt/a/1027.
Notice the section titled "Valid XML Output: Including DOCTYPE Declarations". If you have your resolver set to null, C# may be inserting the internal DTD subset in order to maintain the validity of your XML Document.
Apr 11 '07 #8
dorinbogdan
839 Recognized Expert Contributor
Take a look at http://www.xml.com/lpt/a/1027.
Notice the section titled "Valid XML Output: Including DOCTYPE Declarations". If you have your resolver set to null, C# may be inserting the internal DTD subset in order to maintain the validity of your XML Document.
And the presence of brakets [] will not affect the XML validity.
It's working fine as is.
Apr 11 '07 #9
sekarm
26 New Member
Thank you all for your kind reply,

I have to check my client validation with that xml file. if that bracket is present the validator gives the error message Invalid file. if i manually remove that bracket then i have check the validation its does not thrown error. so its not a correct process for manually removing the bracket. so that i ask that question. i did not know the validation process in client side.

....Sekar
Apr 12 '07 #10

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

Similar topics

2
9452
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and...
3
2341
by: Rob Meade | last post by:
Hi all, I have a login page which has username and password fields, a login button, and 2 validation controls (one for each field) - currently I have controls to display to the summary if the items missing etc.all working fine... However, when the user logs in I fire off to a stored procedure, at this point, unless the login is successful I can return up to about 8 different error numbers in a string which I then split out into an...
14
6310
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
2
4004
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the IIS Server of my Workstation (Win XP) with a text box, button and required field validator, this works fine. If I create the same page on the IIS6 Windows 2003 Server the validation control doesn't stop the post. I've tried different browsers and...
0
1262
by: aeshtry | last post by:
Hello dear friends I have an urgent question. Would you please give me your professional idea? I have an html table containing the ASP.Net validation summary and an ASP.Net label control. The table background has different color than other sections. I want to show the error message inside a section (with different background color) only when an error occurred. This error can be a validation client error (generated by validation controls...
12
2271
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
5
1753
by: Kyle | last post by:
On my Development System, all the page validation controls work fine (WinXP Pro + SP2, VS.NET 2003, .NET v1.1.4322). On the Production System, none of the page validation controls are working (Windows 2000 Server + SP4, .NET v1.1.4322). If one of the client machines access my Development system, everything works as it should, so this isn't a client-side or browser issue (IE 6 + updates).
9
4180
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
11
3001
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
3
2760
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.