Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a console window along with a GUI application ? Pin
LongFangFang30-Dec-13 22:22
LongFangFang30-Dec-13 22:22 
GeneralRe: How to create a console window along with a GUI application ? Pin
Dave Kreskowiak31-Dec-13 2:10
mveDave Kreskowiak31-Dec-13 2:10 
AnswerRe: How to create a console window along with a GUI application ? Pin
OriginalGriff30-Dec-13 22:35
mveOriginalGriff30-Dec-13 22:35 
AnswerRe: How to create a console window along with a GUI application ? Pin
Ravi Bhavnani31-Dec-13 5:54
professionalRavi Bhavnani31-Dec-13 5:54 
Question[Solved] How to check what makes Windows Service stops automatically? Pin
emma.sun.sts30-Dec-13 14:06
emma.sun.sts30-Dec-13 14:06 
AnswerRe: How to check what makes Windows Service stops automatically? Pin
thatraja30-Dec-13 16:12
professionalthatraja30-Dec-13 16:12 
GeneralRe: How to check what makes Windows Service stops automatically? Pin
emma.sun.sts30-Dec-13 22:50
emma.sun.sts30-Dec-13 22:50 
GeneralRe: How to check what makes Windows Service stops automatically? Pin
Dave Kreskowiak31-Dec-13 1:41
mveDave Kreskowiak31-Dec-13 1:41 
GeneralRe: How to check what makes Windows Service stops automatically? Pin
emma.sun.sts1-Jan-14 14:28
emma.sun.sts1-Jan-14 14:28 
GeneralRe: How to check what makes Windows Service stops automatically? Pin
Dave Kreskowiak1-Jan-14 15:14
mveDave Kreskowiak1-Jan-14 15:14 
GeneralRe: How to check what makes Windows Service stops automatically? Pin
emma.sun.sts1-Jan-14 22:15
emma.sun.sts1-Jan-14 22:15 
AnswerRe: How to check what makes Windows Service stops automatically? Pin
jschell31-Dec-13 8:04
jschell31-Dec-13 8:04 
Questionabout GostScript Arguments Pin
delphix530-Dec-13 12:16
delphix530-Dec-13 12:16 
QuestionRotate capture image pixel by pixel 180 degree Pin
Member 1047764030-Dec-13 10:53
Member 1047764030-Dec-13 10:53 
AnswerRe: Rotate capture image pixel by pixel 180 degree Pin
Richard MacCutchan30-Dec-13 22:59
mveRichard MacCutchan30-Dec-13 22:59 
QuestionData scaffolding dynamicdata page issue Pin
vkEE30-Dec-13 10:09
vkEE30-Dec-13 10:09 
AnswerRe: Data scaffolding dynamicdata page issue Pin
Richard MacCutchan30-Dec-13 22:59
mveRichard MacCutchan30-Dec-13 22:59 
QuestionTelerik Report Pin
Obulesh K30-Dec-13 1:18
Obulesh K30-Dec-13 1:18 
AnswerRe: Telerik Report Pin
thatraja30-Dec-13 1:47
professionalthatraja30-Dec-13 1:47 
QuestionPublish partial files via clickonce in winforms VS2010 Pin
kanna86.j30-Dec-13 0:28
kanna86.j30-Dec-13 0:28 
AnswerRe: Publish partial files via clickonce in winforms VS2010 Pin
Dave Kreskowiak30-Dec-13 4:38
mveDave Kreskowiak30-Dec-13 4:38 
Questionselect only distinct child elements from 2 xml files and display it on rich text box. Pin
Arjun Mourya29-Dec-13 21:44
Arjun Mourya29-Dec-13 21:44 
Hi ,

I have two .xml files with contents as below:

demo1.xml
------------
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<agenda>
    <Appointment>
      <Id> 7  </Id>
      <Date> 20060426  </Date>
      <Time> 120000  </Time>
      <Subject> test </Subject>
      <Description> testttt  </Description>
      <Place> paris  </Place>
      <Modtime> 182204  </Modtime>
    </Appointment>
    <Appointment>
      <Id> 8  </Id>
      <Date> 20060426  </Date>
      <Time> 120000  </Time>
      <Subject> whatever  </Subject>
      <Description> whateverrr  </Description>
      <Place> where ever  </Place>
      <Modtime> 182204  </Modtime>
    </Appointment>
</agenda>


demo.xml
-----------
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<agenda>
    <Appointment>
      <Id> 7  </Id>
      <Date> 20060426  </Date>
      <Time> 120000  </Time>
      <Subject> test </Subject>
      <Description> testttt  </Description>
      <Place> paris  </Place>
      <Modtime> 182204  </Modtime>
    </Appointment>
</agenda>


See from the two files above, Id=7 is common in both .xml files.
I want to select Id=8 which is not present in demo.xml.

So my output should be as below:

HTML
<Appointment>
     <Id> 8  </Id>
     <Date> 20060426  </Date>
     <Time> 120000  </Time>
     <Subject> whatever  </Subject>
     <Description> whateverrr  </Description>
     <Place> where ever  </Place>
     <Modtime> 182204  </Modtime>
   </Appointment>


I tried the below code but I could not arrive at what I need.

C#
string origPath = @"F:\demo.xml";
            string inPath = @"F:\demo1.xml";
            XElement xmlObject = XElement.Load(origPath);
            var xDoc = xmlObject.Descendants("Appointment");
            XElement xmlObject1 = XElement.Load(inPath);
            var xDoc1 = xmlObject1.Descendants("Appointment");
            var notIn = xDoc1.Except(xDoc);
            //var notIn1 = xDoc.Except(notIn);
            foreach (XElement ele in notIn)
            {
                richTextBox1.AppendText(ele.ToString() + "\n");
                
            }


When executing the code above I got:

HTML
<Appointment>
      <Id> 7  </Id>
      <Date> 20060426  </Date>
      <Time> 120000  </Time>
      <Subject> test </Subject>
      <Description> testttt  </Description>
      <Place> paris  </Place>
      <Modtime> 182204  </Modtime>
    </Appointment>
    <Appointment>
      <Id> 8  </Id>
      <Date> 20060426  </Date>
      <Time> 120000  </Time>
      <Subject> whatever  </Subject>
      <Description> whateverrr  </Description>
      <Place> where ever  </Place>
      <Modtime> 182204  </Modtime>
    </Appointment>


But the below code provides me the result what actually I need:
C#
double[] numbers1 = { 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 };
double[] numbers2 = { 2.2 };

 IEnumerable<double> onlyInFirstSet = numbers1.Except(numbers2);

 foreach (double number in onlyInFirstSet)
    richTextBox1.AppendText(number.ToString() +"\n");


The immediate above code provided:
2,2.1,2.3,2.4,2.5

Please let me know what is wrong in my code to fetch distinct elements from xml file?

BR,
Arjun

modified 30-Dec-13 5:06am.

QuestionRe: select only distinct child elements from 2 xml files and display it on rich text box. Pin
Richard MacCutchan29-Dec-13 22:57
mveRichard MacCutchan29-Dec-13 22:57 
AnswerRe: select only distinct child elements from 2 xml files and display it on rich text box. Pin
Arjun Mourya29-Dec-13 23:06
Arjun Mourya29-Dec-13 23:06 
GeneralRe: select only distinct child elements from 2 xml files and display it on rich text box. Pin
Richard MacCutchan29-Dec-13 23:55
mveRichard MacCutchan29-Dec-13 23:55 

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.