question

mionshion-3520 avatar image
0 Votes"
mionshion-3520 asked mionshion-3520 commented

C# xml linq for this kind of file.

hello all i did get support the other week and been looking into linq as suggested,

and been looking into it now if i am not mistaken this should work

             XDocument xdoc = new XDocument();
    
             xdoc = XDocument.Load(@"C:\Users\elfen\AppData\Local\PCDJ-DEX3\Database\Database.xml");
    
             var result = from q in xdoc.Descendants("tracks")
                          select new
                          {
                              artist = q.Element("arti").Value,
                              title = q.Element("titl").Value,
                              filename = q.Element("fnam").Value
                                 
                          };
         }

and xml file....
B0qC3hLB



not sure gone through loads of guides cant see why its not picking these up.

kind regards elfenliedtopfan5

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
1 Vote"
Viorel-1 answered mionshion-3520 commented

Check this code:

 var result = from q in xdoc.Root.Elements( "tracks" ).Elements( "track" )
                 select new
                 {
                     artist = q.Attribute( "arti" )?.Value,
                     title = q.Attribute( "titl" )?.Value,
                     filename = q.Attribute( "fnam" )?.Value
    
                 };
 var list = result.ToList( );
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Huge thank you this has worked perfectly :) thank you so much cant belive all i was missing was the .elememnets part

marked as answer and sorry about late reply.

0 Votes 0 ·