Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
QuestionCalculate Plus Minus values from TextBox Pin
M Riaz Bashir23-Feb-11 19:10
M Riaz Bashir23-Feb-11 19:10 
AnswerRe: Calculate Plus Minus values from TextBox Pin
Anurag Gandhi23-Feb-11 20:16
professionalAnurag Gandhi23-Feb-11 20:16 
GeneralRe: Calculate Plus Minus values from TextBox Pin
M Riaz Bashir23-Feb-11 20:29
M Riaz Bashir23-Feb-11 20:29 
GeneralRe: Calculate Plus Minus values from TextBox Pin
OriginalGriff23-Feb-11 20:56
mveOriginalGriff23-Feb-11 20:56 
GeneralRe: Calculate Plus Minus values from TextBox Pin
Anurag Gandhi23-Feb-11 21:27
professionalAnurag Gandhi23-Feb-11 21:27 
GeneralRe: Calculate Plus Minus values from TextBox Pin
OriginalGriff23-Feb-11 23:07
mveOriginalGriff23-Feb-11 23:07 
GeneralRe: Calculate Plus Minus values from TextBox Pin
Pravin Patil, Mumbai23-Feb-11 22:31
Pravin Patil, Mumbai23-Feb-11 22:31 
QuestionLINQ to xml query Pin
faheemnadeem23-Feb-11 18:34
faheemnadeem23-Feb-11 18:34 
Hi,
I am trying to delete some nodes from an xml document. I am using LINQ to xml and want to stick to this approach. Here is my XML document:

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <Clips>
    <Clip ID="1" Sequence="1">
      <Name></Name>
      <Description></Description>
      <Location></Location>
      <Duration></Duration>
      <Images>
        <Image ID="1">
          <Name></Name>
          <Description></Description>
          <Location></Location>
          <StartTime></StartTime>
          <EndTime></EndTime>
        </Image>
      </Images>
    </Clip>
    <Clip ID="2" Sequence="1">
      <Name>Bazingaaa</Name>
      <Description>Masdljaslda</Description>
      <Location>C:\Videos</Location>
      <Duration>00:00:30</Duration>
      <Images>
        <Image ID="1">
          <Name>Faheem</Name>
          <Description>MyImage</Description>
          <Location>C:\Images</Location>
          <StartTime>00:00:00</StartTime>
          <EndTime>00:00:10</EndTime>
        </Image>
        <Image ID="2">
          <Name>Fawaz</Name>
          <Description>MyImage</Description>
          <Location>C:\Images</Location>
          <StartTime>00:00:00</StartTime>
          <EndTime>00:00:10</EndTime>
        </Image>
      </Images>
    </Clip>
  </Clips>
</Project>


I have to perform two cases. 1. Delete clip node based on ID. 2. Clear whole project root tag.
I am using the following code to delete nodes.

// Obtain the first clip entry
                            IEnumerable<XElement> clip = (from c in this.oProjectDoc.Element("Project").Element("Clips").Elements("Clip")
                                   where c.Attribute("ID").Value.Equals(ID)
                                   select c);
                            
                            // Delete clip entry
                            foreach (XElement xe in clip)
                                xe.Remove();

                            // Save updated options document to file system
                            this.oProjectDoc.Save(this.oProjectPath.FullName);


Have tried this as well.

var q = from node in oProjectDoc.Root.DescendantsAndSelf("Clips")
        let attr = node.Attribute("ID")
        where attr != null && attr.Value == clipId
        select node;
q.ToList().ForEach(x => x.Remove());
oProjectDoc.Save(this.oProjectPath.FullName);


Problem happens when i try to delete the last clip node or the clear the whole root "Project" tag. I get a lingering end node tag. Like:

</Clip>


Any solutions to that. Kindly please also tell me how can clear all my nodes from xml document. i.e. totally empty my xml document and start afresh without deleting the xml file.

Thanks in advance

Regards...
Smile | :)
AnswerRe: LINQ to xml query Pin
#realJSOP24-Feb-11 4:55
professional#realJSOP24-Feb-11 4:55 
QuestionHow to display a warning message in file uploading when the uploading file is open in user machine... Pin
Rocky2323-Feb-11 18:05
Rocky2323-Feb-11 18:05 
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Wayne Gaylard23-Feb-11 22:20
professionalWayne Gaylard23-Feb-11 22:20 
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Rocky2323-Feb-11 22:42
Rocky2323-Feb-11 22:42 
GeneralRe: How to display a warning message in file uploading when the uploading file is open in user machine... Pin
Wayne Gaylard23-Feb-11 22:52
professionalWayne Gaylard23-Feb-11 22:52 
Questionc# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 15:13
lanpartyes23-Feb-11 15:13 
AnswerRe: c# Need help getting WPF window to draw behind desktop icons Pin
SledgeHammer0123-Feb-11 18:13
SledgeHammer0123-Feb-11 18:13 
GeneralRe: c# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 23:49
lanpartyes23-Feb-11 23:49 
Questionvb.net to c#.net Pin
David C# Hobbyist.23-Feb-11 14:49
professionalDavid C# Hobbyist.23-Feb-11 14:49 
AnswerRe: vb.net to c#.net Pin
RobCroll23-Feb-11 16:18
RobCroll23-Feb-11 16:18 
AnswerRe: vb.net to c#.net Pin
thatraja23-Feb-11 16:29
professionalthatraja23-Feb-11 16:29 
AnswerRe: vb.net to c#.net Pin
Pravin Patil, Mumbai23-Feb-11 23:49
Pravin Patil, Mumbai23-Feb-11 23:49 
QuestionQuestion about adding/removing account Pin
turbosupramk323-Feb-11 9:05
turbosupramk323-Feb-11 9:05 
AnswerRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 9:42
GenJerDan23-Feb-11 9:42 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 10:14
turbosupramk323-Feb-11 10:14 
GeneralRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 10:38
GenJerDan23-Feb-11 10:38 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:05
turbosupramk323-Feb-11 11:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.