开发者

Unable to perfom LINQ on this XML

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 the XML file is:

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile">
    <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>
</SolutionProfi开发者_运维问答le>

This is a SCSF and CAB XML file. If I remove the following tag from the XML query works fine.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜