Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dynamic created radio buttons wont execute event on click (c# .net ) Pin
Gopi Kishan Mariyala22-Jan-14 22:24
Gopi Kishan Mariyala22-Jan-14 22:24 
GeneralRe: Dynamic created radio buttons wont execute event on click (c# .net ) Pin
salar136923-Jan-14 6:53
salar136923-Jan-14 6:53 
QuestionPainfully Slow Operation Pin
eddieangel22-Jan-14 11:07
eddieangel22-Jan-14 11:07 
AnswerRe: Painfully Slow Operation Pin
Matt T Heffron22-Jan-14 14:19
professionalMatt T Heffron22-Jan-14 14:19 
GeneralRe: Painfully Slow Operation Pin
eddieangel23-Jan-14 5:51
eddieangel23-Jan-14 5:51 
GeneralRe: Painfully Slow Operation Pin
Dave Kreskowiak23-Jan-14 7:48
mveDave Kreskowiak23-Jan-14 7:48 
GeneralRe: Painfully Slow Operation Pin
eddieangel23-Jan-14 7:59
eddieangel23-Jan-14 7:59 
QuestionRead XML values (attributes and elements) with C# Pin
SJR_122-Jan-14 5:14
SJR_122-Jan-14 5:14 
XML File

XML
<Log>
    <HomeItem id="2">
        <Time>1/8/2014 3:21:47 PM</Time>
        <HasNewAddress>Y</HasNewAddress>
        <AddressType>N</AddressType>
        <Description>myDescrip</Description>
        <Item/>
        <Title/>
    </HomeItem>
    <HomeItem id="3">
        <Time>1/8/2014 6:52:47 PM</Time>
        <HasNewAddress>Y</HasNewAddress>
        <AddressType>N</AddressType>
        <Description>myDescrip2</Description>
        <Item>
            <ItemNumber id="0">
                <Name>Coffee</Name>
                <ItemDescrip>I Descrip1</ItemDescrip>
            </ItemNumber>
            <ItemNumber id="1">
                <Name>Tea</Name>
                <ItemDescrip>I Descrip 2</ItemDescrip>
            </ItemNumber>
            <ItemNumber id="2">
                <Name>Milk</Name>
                <ItemDescrip>I Descrip 3</ItemDescrip>
            </ItemNumber>
        </Item>
        <Title/>
    </HomeItem>
    <HomeItem id="4">
        <Time>1/8/2014 7:35:47 PM</Time>
        <HasNewAddress>Y</HasNewAddress>
        <AddressType>N</AddressType>
        <Description>my Descrip 3</Description>
        <Item>
            <ItemNumber id="7">
                <Name>Juice</Name>
                <ItemDescrip>I Descrip 4</ItemDescrip>
            </ItemNumber>
            <ItemNumber id="8">
                <Name>Tea</Name>
                <ItemDescrip>I Descrip 6</ItemDescrip>
            </ItemNumber>
            <ItemNumber id="9">
                <Name>Milk</Name>
                <ItemDescrip>I Descrip 7</ItemDescrip>
            </ItemNumber>
        </Item>
        <Title>The Title</Title>
    </HomeItem>
    <HomeItem id="5">
        <Time>1/8/2014 12:21:47 PM</Time>
        <HasNewAddress>Y</HasNewAddress>
        <AddressType>N</AddressType>
        <Description>myDescrip 8</Description>
        <Item/>
        <Title/>
    </HomeItem>
</Log>


I want to loop through the results and assign variables. Here is my code

C#
public void Today3()
     {
         XDocument xDoc = XDocument.Load(@"C:\Results\XMLTry.xml");
     var q = from c in xDoc.Descendants("HomeItem")
             select (string)c.Element("Description") + " " +
                 (string)c.Element("Time") + " Attribute = " +
                 (int)c.Attribute("id");


                 foreach (string name in q)
                    Console.WriteLine("My stuff = {0}", name);
     }



My results are displayed as a string:(sample of results)
My stuff = myDescrip2 1/8/2014 6:52:47 PM Attribute = 3
My stuff = my Descrip 3 1/8/2014 7:35:47 PM Attribute = 4

How can I get the results to be like:
sDescrip = myDescrip2
time = 1/8/2014 6:52:47 PM
Id = 3

I tried name.value and q.value and many other combinations and can't come up with what I'm looking for.

Thank You
AnswerRe: Read XML values (attributes and elements) with C# Pin
Christian Wulff22-Jan-14 23:38
Christian Wulff22-Jan-14 23:38 
GeneralRe: Read XML values (attributes and elements) with C# Pin
SJR_123-Jan-14 4:59
SJR_123-Jan-14 4:59 
GeneralRe: Read XML values (attributes and elements) with C# Pin
Christian Wulff23-Jan-14 5:06
Christian Wulff23-Jan-14 5:06 
GeneralRe: Read XML values (attributes and elements) with C# Pin
SJR_123-Jan-14 5:33
SJR_123-Jan-14 5:33 
GeneralRe: Read XML values (attributes and elements) with C# Pin
Christian Wulff23-Jan-14 7:44
Christian Wulff23-Jan-14 7:44 
GeneralRe: Read XML values (attributes and elements) with C# Pin
SJR_123-Jan-14 9:03
SJR_123-Jan-14 9:03 
QuestionWindows Process and MEF Pin
Member 1027274822-Jan-14 3:13
Member 1027274822-Jan-14 3:13 
AnswerRe: Windows Process and MEF Pin
Eddy Vluggen22-Jan-14 8:28
professionalEddy Vluggen22-Jan-14 8:28 
AnswerRe: Windows Process and MEF Pin
Ron Beyer22-Jan-14 8:40
professionalRon Beyer22-Jan-14 8:40 
Questionexecuting rake from C# app Pin
lune1221-Jan-14 22:44
lune1221-Jan-14 22:44 
AnswerRe: executing rake from C# app Pin
Pete O'Hanlon21-Jan-14 23:02
mvePete O'Hanlon21-Jan-14 23:02 
GeneralRe: executing rake from C# app Pin
lune1222-Jan-14 0:33
lune1222-Jan-14 0:33 
GeneralRe: executing rake from C# app Pin
Pete O'Hanlon22-Jan-14 0:35
mvePete O'Hanlon22-Jan-14 0:35 
GeneralRe: executing rake from C# app Pin
lune1222-Jan-14 0:51
lune1222-Jan-14 0:51 
GeneralRe: executing rake from C# app Pin
Pete O'Hanlon22-Jan-14 0:57
mvePete O'Hanlon22-Jan-14 0:57 
AnswerRe: executing rake from C# app Pin
Bernhard Hiller22-Jan-14 20:34
Bernhard Hiller22-Jan-14 20:34 
QuestionError in DataGridView Filter Pin
a-erfani21-Jan-14 22:18
a-erfani21-Jan-14 22:18 

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.