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

C#

 
AnswerRe: C# take xml and store in sql server Pin
PIEBALDconsult28-Aug-12 19:19
mvePIEBALDconsult28-Aug-12 19:19 
AnswerRe: C# take xml and store in sql server Pin
BobJanova28-Aug-12 23:39
BobJanova28-Aug-12 23:39 
GeneralRe: C# take xml and store in sql server Pin
sc steinhayse29-Aug-12 3:51
sc steinhayse29-Aug-12 3:51 
GeneralRe: C# take xml and store in sql server Pin
BobJanova29-Aug-12 4:52
BobJanova29-Aug-12 4:52 
AnswerRe: C# take xml and store in sql server Pin
V.29-Aug-12 2:04
professionalV.29-Aug-12 2:04 
GeneralRe: C# take xml and store in sql server Pin
sc steinhayse29-Aug-12 3:51
sc steinhayse29-Aug-12 3:51 
AnswerRe: C# take xml and store in sql server Pin
jschell30-Aug-12 8:59
jschell30-Aug-12 8:59 
QuestionC# use linq to parse xml Pin
dcof28-Aug-12 17:28
dcof28-Aug-12 17:28 
I would like to parse an xml file using linq in a C#2010 application. Listed below you will find an example of an xml file I want to parse. I would like to use the code listed below to parse the an xml file. Thus I am wondering if you can show me how to use the code I listed below to parse the xml displayed below and/or show me code that will accomplish this goal?

The following is the code:
using System;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        XDocument document = XDocument.Load(@"d:\test.xml");

        var priceInfo = from e in document.Descendants("MPrice").Elements("Price")
                        let start = DateTime.Parse(e.Descendants("StartDt").FirstOrDefault().Value)
                        let end = DateTime.Parse(e.Descendants("EndDt").FirstOrDefault().Value)
                        where start < DateTime.Now && end > DateTime.Now
                        select new { Id = e.Parent.Element("Id").Value, ListPrice = e.Element("ListPrice").Value };

        Console.WriteLine(priceInfo.FirstOrDefault().Id);
        Console.WriteLine(priceInfo.FirstOrDefault().ListPrice);
    }
}

The following is the metatag:
<ns2:RetsubPack serviceSuccessful="true" returnCode="0" xmlns:ns2="http://test1/test">
    <statusDescription>Package Details retrieved Successfully</statusDescription>
    <PackageDetails>
        <Type>type2</Type>
        <Category>dog</Category>
        <ContName>Co 1</ContgName>
        <TotalTrans>0</TotalTrans>
     </PackageDetails>
    <NumberOfDocuments>3</NumberOfDocuments>
    <subDocuments attachmentId="xx1">
        <DocumentMetadata>
            <DocumentTypeCode>Spreadsheet1</DocumentTypeCode>
            <PackageId>pkg1</PackageId>
        </DocumentMetadata>
    </subDocuments>
    <subDocuments attachmentId="xx2">
        <DocumentMetadata>
            <DocumentTypeCode>Spreadsheet2</DocumentTypeCode>
            <PackageId>pkg1</PackageId>
        </DocumentMetadata>
    </subDocuments>
    <subDocuments attachmentId="xx3">
       
</ns2:RetsubPack>

AnswerRe: C# use linq to parse xml Pin
PIEBALDconsult28-Aug-12 19:21
mvePIEBALDconsult28-Aug-12 19:21 
AnswerRe: C# use linq to parse xml Pin
V.29-Aug-12 2:00
professionalV.29-Aug-12 2:00 
GeneralRe: C# use linq to parse xml Pin
dcof29-Aug-12 10:56
dcof29-Aug-12 10:56 
Questionif webbrowser hangs, then retry, how to check if hanging c# Pin
Member 938944428-Aug-12 13:52
Member 938944428-Aug-12 13:52 
AnswerRe: if webbrowser hangs, then retry, how to check if hanging c# Pin
Shameel28-Aug-12 14:54
professionalShameel28-Aug-12 14:54 
GeneralRe: if webbrowser hangs, then retry, how to check if hanging c# Pin
Member 938944428-Aug-12 16:26
Member 938944428-Aug-12 16:26 
AnswerRe: if webbrowser hangs, then retry, how to check if hanging c# Pin
Shameel28-Aug-12 19:30
professionalShameel28-Aug-12 19:30 
AnswerRe: if webbrowser hangs, then retry, how to check if hanging c# Pin
Eddy Vluggen28-Aug-12 23:09
professionalEddy Vluggen28-Aug-12 23:09 
GeneralRe: if webbrowser hangs, then retry, how to check if hanging c# Pin
Member 88893234-Sep-12 3:52
Member 88893234-Sep-12 3:52 
QuestionSecurity of Passwords Pin
zephaneas28-Aug-12 13:18
zephaneas28-Aug-12 13:18 
AnswerRe: Security of Passwords Pin
jschell28-Aug-12 14:00
jschell28-Aug-12 14:00 
AnswerRe: Security of Passwords Pin
Peter_in_278028-Aug-12 15:13
professionalPeter_in_278028-Aug-12 15:13 
GeneralRe: Security of Passwords Pin
Paul Conrad28-Aug-12 18:24
professionalPaul Conrad28-Aug-12 18:24 
AnswerRe: Security of Passwords Pin
Paul Conrad28-Aug-12 18:25
professionalPaul Conrad28-Aug-12 18:25 
AnswerRe: Security of Passwords Pin
Bernhard Hiller28-Aug-12 21:42
Bernhard Hiller28-Aug-12 21:42 
AnswerRe: Security of Passwords Pin
BobJanova28-Aug-12 23:36
BobJanova28-Aug-12 23:36 
AnswerRe: Security of Passwords Pin
Dave Kreskowiak29-Aug-12 2:06
mveDave Kreskowiak29-Aug-12 2:06 

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.