verifier et extraire attribut
hello,
j'ai un fichier XML:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <Databases>
<Database SiteCount="2" Name="WSS_Content" DataSource="xxx">
<Site Id="ef5d110e-3562-4e4f-bdf4-0ee688e92701" OwnerLogin="xxxx" InSiteMap="True">
<Webs Count="1">
<Web Id="eb0591b4-0ccd-4834-8f97-abe9974b8a32" Url="site/xxxxxxa" LanguageId="1033" TemplateName="xxx#0" TemplateId="10001">
<Features>
<Feature Id="00bfea71-c796-4402-9f2f-0eb9a6e71b18" Count="1" DisplayName="WebPageLibrary" InstallPath="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\WebPageLibrary" Status="Installed" />
</Features>
<EventReceiverAssemblies>
<EventReceiverAssembly Name="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Status="Installed" />
</EventReceiverAssemblies>
<WebParts>
<WebPart Id="ce9aa113-48cf-ddee-0c03-597445e5b7ab" Count="1" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ImageWebPart" />
<WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="35" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListFormWebPart" />
<WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="35" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListViewWebPart" />
</WebParts>
<CustomListViews />
<SetupFiles>
<SetupFile Path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\1033\STS\doctemp\word\wdtmpl.doc" Count="3" Status="Installed" />
<SetupFile Path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\BasicWebParts\MSContentEditor.dwp" Count="1" Status="Installed" />
</SetupFiles>
</Web>
</Webs>
</Site>
<Site Id="389fa2ac-4b8a-4704-ad98-e49619c981a0" OwnerLogin="xxx\srv-xxx" InSiteMap="True">
<Webs Count="2">
<Web Id="3820015a-56cf-41b8-9607-bbed7775f514" Url="/site/xxxxx" LanguageId="1033" TemplateName="OSRV#0" TemplateId="40">
<Features>
<Feature Id="00bfea71-5932-4f9c-ad71-1557e5751100" Count="1" DisplayName="IssuesList" InstallPath="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\IssuesList" Status="Installed" />
</Features>
<EventReceiverAssemblies>
<EventReceiverAssembly Name="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Status="Installed" />
<EventReceiverAssembly Name="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Status="Installed" />
</EventReceiverAssemblies>
<WebParts>
<WebPart Id="d55b3b6b-6281-707b-73d0-0c49581475ad" Count="1" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.SearchStatsWebPart" />
<WebPart Id="6172b769-e922-1e5e-b706-1073173cbce3" Count="1" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.CompletedCrawls" />
<WebPart Id="bc0158dd-a329-57ce-3563-1afacb17ec6c" Count="1" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.SystemStatus" />
<WebPart Id="f5c3ff60-e752-3a90-84f8-3677f8384e2d" Count="2" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart" />
<WebPart Id="f2c50a02-9894-4ace-bb3f-4146a24cd940" Count="2" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.SearchPagingWebPart" />
<WebPart Id="c54a0f4e-d855-ad45-ef85-4e67abf15a4d" Count="1" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.ActiveCrawls" />
<WebPart Id="e60f6c95-e86c-4717-2c0d-6d8563c9caf7" Count="1" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ContentEditorWebPart" />
<WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="29" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListFormWebPart" />
<WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="19" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListViewWebPart" />
<WebPart Id="74bd016c-baa0-14a8-d5d8-b75dc7e6f429" Count="1" Status="Installed" Type="Microsoft.SharePoint.Portal.WebControls.ContactFieldControl" />
<WebPart Id="fb35a198-aea0-3c26-e40c-df473fe9b07b" Count="2" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.HighConfidenceWebPart" />
<WebPart Id="669602d9-e116-ccb8-eea3-e37ad589b14b" Count="1" Status="Installed" Type="Microsoft.Office.Server.Search.WebControls.SearchSummaryWebPart" />
<WebPart Id="f5897322-ddd4-c990-d012-f9d4fe2180ad" Count="2" Status="Installed" Type="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" />
</WebParts>
<CustomListViews />
<SetupFiles>
<SetupFile Path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\1033\STS\doctemp\word\wdtmpl.doc" Count="2" Status="Installed" />
</SetupFiles>
</Web>
<Web Id="d2e7ca33-fc74-4907-a34f-4c5ae1dbde84" Url="/ssp/admin/xxxxa" LanguageId="1033" TemplateName="PROFILES#0" TemplateId="51">
<Features>
<Feature Id="00bfea71-c796-4402-9f2f-0eb9a6e71b18" Count="1" DisplayName="WebPageLibrary" InstallPath="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\WebPageLibrary" Status="Installed" />
</Features>
<EventReceiverAssemblies />
<WebParts>
<WebPart Id="293e8d0e-486f-e21e-40e3-75bfb77202de" Count="6" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListFormWebPart" />
<WebPart Id="2242cce6-491a-657a-c8ee-b10a2a993eda" Count="5" Status="Installed" Type="Microsoft.SharePoint.WebPartPages.ListViewWebPart" />
<WebPart Id="f6bfd4dd-e6b5-7cb0-e080-e7674fcdd856" Count="1" Status="Installed" Type="Microsoft.SharePoint.Portal.WebControls.BusinessDataDetailsWebPart" />
</WebParts>
<CustomListViews />
<SetupFiles>
<SetupFile Path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\1033\STS\doctemp\word\wdtmpl.doc" Count="1" Status="Installed" />
</SetupFiles>
</Web>
</Webs>
</Site>
</Database>
</Databases> |
je veux extraire l'attribut 'Url' du tag 'Web' uniquement si l'attribut 'id' de 'WebPart' vaut: 'f6bfd4dd-e6b5-7cb0-e080-e7674fcdd856'
l'expression xpath que j'utilise est:
Code:
"//Web[WebParts/WebPart//@*[1][contains(.,'f6bfd4dd-e6b5-7cb0-e080-e7674fcdd856')]]/@*[2]"
comme vous voyez ce n'est ni flexible ni intelligible :aie:
avez vous une autre approche plus classe pour faire ce traitement ;)
merci @ vous :D