Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
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 
QuestionHow to upld pdf with description?? Pin
Member 1049383529-Dec-13 17:40
Member 1049383529-Dec-13 17:40 
AnswerRe: How to upld pdf with description?? Pin
Dave Kreskowiak29-Dec-13 18:05
mveDave Kreskowiak29-Dec-13 18:05 
AnswerRe: How to upld pdf with description?? Pin
ZurdoDev1-Jan-14 15:28
professionalZurdoDev1-Jan-14 15:28 
QuestionInterrupting service startup Pin
Fred283429-Dec-13 4:38
Fred283429-Dec-13 4:38 
AnswerRe: Interrupting service startup Pin
Ravi Bhavnani29-Dec-13 5:31
professionalRavi Bhavnani29-Dec-13 5:31 
AnswerRe: Interrupting service startup Pin
Dave Kreskowiak29-Dec-13 5:43
mveDave Kreskowiak29-Dec-13 5:43 
GeneralRe: Interrupting service startup Pin
Fred283429-Dec-13 7:26
Fred283429-Dec-13 7:26 
QuestionCtrl + MouseClick using PostMessage is not working for DataGridview. Pin
aks.29-Dec-13 3:03
aks.29-Dec-13 3:03 
AnswerRe: Ctrl + MouseClick using PostMessage is not working for DataGridview. Pin
Eddy Vluggen29-Dec-13 3:30
professionalEddy Vluggen29-Dec-13 3:30 
GeneralRe: Ctrl + MouseClick using PostMessage is not working for DataGridview. Pin
aks.29-Dec-13 20:36
aks.29-Dec-13 20:36 
QuestionRe: Ctrl + MouseClick using PostMessage is not working for DataGridview. Pin
Eddy Vluggen30-Dec-13 2:40
professionalEddy Vluggen30-Dec-13 2:40 
AnswerRe: Ctrl + MouseClick using PostMessage is not working for DataGridview. Pin
aks.30-Dec-13 3:39
aks.30-Dec-13 3:39 
GeneralRe: Ctrl + MouseClick using PostMessage is not working for DataGridview. Pin
Eddy Vluggen2-Jan-14 8:00
professionalEddy Vluggen2-Jan-14 8:00 
QuestionItemCommand(Repeater) not getting fired with modalpopup. Pin
Kundan Saw28-Dec-13 4:08
Kundan Saw28-Dec-13 4:08 

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.