getting current element id node for select

i have an xml file in my web project so i need edit some of them when user wants and i write codes like this;

publicvoid EditAnnouncement(int intAnnID,string strAnnTitle,string strAnnBody)

{

XmlDocument annDoc =newXmlDocument();

annDoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/Announcement.xml"));

string xpathExpression =string.Format("//annPanel/ann[annID={0}]", intAnnID);

XmlNode ann = annDoc.SelectSingleNode(xpathExpression);

if (ann ==null)

{

thrownewException(string.Format("Element 'ann' with id ='{0}' not found"), intAnnID);

}

XmlElement annTitle = (XmlElement)ann.SelectSingleNode("annTitle");

annTitle.InnerText = strAnnTitle;

XmlElement annBody = (XmlElement)ann.SelectSingleNode("annBody");

annTitle.InnerText = strAnnBody;

annDoc.Save(HttpContext.Current.Server.MapPath("~/App_Data/Announcement.xml"));

}

but i need intannID variable from somewhere how can i get this for current node which user wants to edit?

i think that i must write a function that gets the current announcement id node innertext which user want to edit ; and set it to any variable likeabc=getID(); and after call editAnnouncement func. (EditAnnoncement(abc,bb,cc) ) but i couldnt write getID func; how can i select innertext of current announcement id ?

this is my xml;

<annPanel>

<ann>

<annID></annID>

<annTitle></annTitle>

<annBody></annBody>

<annPubDate>

<annDate></annDate>

<annTime></annTime>

</annPubDate>

</ann>

</annPanel>

[4753 byte] By [Radith] at [2007-12-23]
# 1

It’s impossible to write getID() without any input arguments.

You should take some input from the user (current node, line number, list item number, etc.) otherwise your program would need to read user’s mind to guess what Announcement he/she wants to edit.

The answer on your question depends on how you collect information from the user.

SergeyDubinets-MSFT at 2007-8-30 > top of Msdn Tech,.NET Development,XML and the .NET Framework...

.NET Development

Site Classified