node validation
public
classAddAnnouncement{
publicvoid _AddAnnouncement(){
XmlDocument newAnnDoc =newXmlDocument();newAnnDoc.Load(
"~/App_Data/Announcement.xml");XmlNode newAnn = newAnnDoc.CreateNode(XmlNodeType.Element,"ann",null);XmlNode Id = newAnnDoc.CreateNode(XmlNodeType.Element,"annID",null);XmlNode Title = newAnnDoc.CreateNode(XmlNodeType.Element,"annTitle",null);XmlNode Body = newAnnDoc.CreateNode(XmlNodeType.Element,"annBody",null);XmlNode Date = newAnnDoc.CreateNode(XmlNodeType.Element,"annDate",null);XmlNode Priority = newAnnDoc.CreateNode(XmlNodeType.Element,"annPriority",null);XmlNode Sender = newAnnDoc.CreateNode(XmlNodeType.Element,"annSender",null);XmlElement annPanel = newAnnDoc.DocumentElement;annPanel.AppendChild(newAnn);
newAnn.AppendChild(Id);
newAnn.AppendChild(Title);
newAnn.AppendChild(Body);
newAnn.AppendChild(Date);
newAnn.AppendChild(Priority);
newAnn.AppendChild(Sender);
}
}
but i need when my method called i want that some child must add itself to xmlfile outo like annID,annDate
what is the way ; must i do it here or from my schema?
[3374 byte] By [
Radith] at [2007-12-22]
here is my xml file;
<?
xml version="1.0" encoding="iso-8859-9"?>
<annPanel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AnnSchema.xsd" >
<ann>
<annID></annID>
<annTitle></annTitle>
<annBody></annBody>
<annDate></annDate>
<annPriority></annPriority>
<annSender></annSender>
</ann>
</annPanel>
it must seem like this but ID and Date must assign automatically;
It's hard to understand what is the problem or what you want to achive.
Can you, please, reformulate your question.
Thanks.
like this int a=0; and id.?( maybe value;;; i dont know what mus be after dot)=a; a++;
but i found my answer it is like this;
XmlDocument
annDoc = new XmlDocument();annDoc.Load(
"~/App_Code/Announcement.xml");XmlNode nodeLast;XmlNode root = annDoc.DocumentElement;nodeLast = annDoc.SelectSingleNodes(
"//annPanel/ann[position()=last()]");if (nodeLast != null)return ++Convert.ToInt32(nodeLast.InnerText); i wrote method like above codes and
id.value = getID(); in my first codes;
thanks your interest too much ;
your sincerely;
In debugger you can see what is the actual value of the InnerText property.
From you sample it mposible to deduct.
If this value is not a valid integer how you expect to increment it?