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
9 2592
Please post your code or a part of it that can be tested.
Thanks,
Dorin.
Oh, and post also the XML file.
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 - <?xml version="1.0" encoding="utf-8"?>
-
<!DOCTYPE note SYSTEM "note.dtd">
-
<ZooRoot>
-
<ZooTable Name="Crazy Zoo" Address="32 Turtle Lane" City="Austin" State="TX" Zip="12345">
-
<Classification Type="Reptiles" />
-
<Classification Type="Birds" />
-
<Classification Type="Primates" />
-
</ZooTable>
-
<ZooTable Name="Chicago Zoo" Address="23 Zebra Ave" City="Chicago" State="IL">
-
<Classification Type="Fish" />
-
<Classification Type="Mammals" />
-
<Classification Type="Primates" />
-
</ZooTable>
-
<ZooTable Name="Hungry Zoo" Address="45 Lion st" City="Miami" State="FL" Zip="33122">
-
<Classification Type="Arachnids" />
-
<Classification Type="Rodents" />
-
</ZooTable>
-
</ZooRoot>
I have modified the above xml file through below this code, - using System.xml;
-
XmlDocument Doc = new XmlDocument();
-
Doc.XmlResolver = null;
-
Doc.Load(@"E:\sample.xml");
-
XmlNodeList RootNode = Doc.GetElementsByTagName("Classification");
-
foreach (XmlNode filesnode in RootNode)
-
{
-
//.ChildNodes[0].RemoveAll();
-
filesnode.RemoveAll();
-
-
XmlNode createnode = Doc.CreateElement("Animal");
-
XmlAttribute attr = Doc.CreateAttribute("AnimalName");
-
attr.Value = "Lion";
-
createnode.Attributes.SetNamedItem(attr);
-
// Creat Attribute For New Node
-
filesnode.AppendChild(createnode);
-
}
-
Doc.Save(@"E:\sample.xml");
- <?xml version="1.0" encoding="utf-8"?>
-
<!DOCTYPE note SYSTEM "note.dtd"[]>
-
-
note it []
-
-
-
<ZooRoot>
-
<ZooTable Name="Crazy Zoo" Address="32 Turtle Lane" City="Austin" State="TX" Zip="12345">
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
</ZooTable>
-
<ZooTable Name="Chicago Zoo" Address="23 Zebra Ave" City="Chicago" State="IL">
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
</ZooTable>
-
<ZooTable Name="Hungry Zoo" Address="45 Lion st" City="Miami" State="FL" Zip="33122">
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
<Classification>
-
<Animal AnimalName="Lion" />
-
</Classification>
-
</ZooTable>
-
</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
Do you have the note.dtd file too?
Its not necessary Dorin. i have given the code
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
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.
Motoma 3,237
Recognized Expert Specialist
What Validator are you using? What is the exact message you are getting?
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.
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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!
|
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...
|
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...
| |
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
|
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).
|
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.)
|
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...
|
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,
|
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...
| |
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...
|
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |