tags:

views:

35

answers:

1

hi i have an xml file. i am unable to perform any XLINQ query on this xml..

i also used LINQPad to test. but it is not returning any result:(

sample query

XDocument doc = XDocument.Load(@"G:\Plugins.xml");

    var res = from plugin in doc.Descendants("Modules")
                select plugin;


    res.Dump();

and xml file is

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile"&gt;
  <Modules>

    <ModuleInfo AssemblyFile="xxxx.dll" />
    <ModuleInfo AssemblyFile="xxxx.dll" />
    <ModuleInfo AssemblyFile="xxxx.dll" />
    <ModuleInfo AssemblyFile="xxxxx.dll" />
    <ModuleInfo AssemblyFile="xxxxx.dll" />       

    <ModuleInfo AssemblyFile="xxxxxx.dll" />   

  </Modules>
</SolutionProfile>

this is SCSF & CAB xml file. if i remove following tag from xml query works fine

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile"&gt;
</SolutionProfile>
A: 

The issue is not with your SolutionProfile tags, but rather the presence of the xmlns attribute in it.

Duplicate of an existing SO question. Look here for the exact answer.

Oh, and you'll be needing an extra "/" on the end of your namespace if you follow the solution in the link.

Xiaofu
thanks. problem solved. it was due to xmlns
Mohsan