Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Struggling with this XPath expression, basically I need to extract the assembly name from a piece of xaml like this:

VB
<Modularity:ModuleCatalog
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism"
    xmlns:AppInfo="clr-namespace:Example.Common.Services.Prism.Modularity;assembly=Example.Common.Services">
    <Modularity:ModuleInfoGroup InitializationMode="OnDemand">
        <AppInfo:ApplicationModuleInfo
            ModuleName="Administration"
            ModuleType="Example.UI.Administration.AdministrationModule, Example.UI.Administration, Version=1.2.1.1, Culture=neutral, PublicKeyToken=537c3450b3658434"
            Ref="Example.UI.Administration.xap" />
        <AppInfo:ApplicationModuleInfo
            ModuleName="Prescribing"
            ModuleType="Example.UI.Prescribing.PrescribingModule, Example.UI.Prescribing, Version=1.24.2.1, Culture=neutral, PublicKeyToken=537c3450b3658434"
            Ref="Example.UI.Prescribing.xap" />
        <AppInfo:ApplicationModuleInfo
            ModuleName="SampleModule"
            ModuleType="Example.UI.SampleModule.SampleModuleModule, Example.UI.SampleModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=537c3450b3658434"
            Ref="Example.UI.SampleModule.xap" />
    </Modularity:ModuleInfoGroup>
</Modularity:ModuleCatalog>


I am basically trying to get "Example.UI.SampleModule" etc. At the moment my expression is as follows:

.//*[local-name() = 'ApplicationModuleInfo']/@ModuleType[substring-after(., ',')][substring-before(.,',')]
But it appears as if the substrings are being completly ignored as the full type names are still found. I'm wondering if using "." as current transform is the correct thing to do?? I.e
substring-before(., ",")
is "." correct?
Posted
Comments
Mehdi Gholam 13-Oct-11 0:01am    
Why don't you use Regx?
Phillip Donegan 13-Oct-11 2:56am    
I could but I was under the impression that when dealing with XML, XPath is what should be used since it understands structure not Regex.
Mehdi Gholam 13-Oct-11 3:12am    
I was never a fan of XPath, its even worse than regex. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900