XML分解实例

原帖:http://blog.youkuaiyun.com/htl258/archive/2010/04/14/5484583.aspx

 

declare @xml xml =

'<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/UpdateHandlers/CommandLineInstallation" xmlns:bar="http://schemas.microsoft.com/msus/2002/12/BaseApplicabilityRules" xmlns:upd="http://schemas.microsoft.com/msus/2002/12/Update">

    <upd:UpdateIdentity UpdateID="9f79459a-d72e-49fc-acb0-1adbb2e63686" RevisionNumber="103"/>

    <upd:Properties DefaultPropertiesLanguage="en" UpdateType="Software" Handler="http://schemas.microsoft.com/msus/2002/12/UpdateHandlers/CommandLineInstallation" PublicationState="Published" CreationDate="2005-04-26T08:21:13.989Z" PublisherID="395392a0-19c0-48b7-a927-f7c15066d905" MaxDownloadSize="3320008" MinDownloadSize="0">

        <upd:InstallationBehavior RebootBehavior="CanRequestReboot"/>

        <upd:Language>zh-cn</upd:Language>

    </upd:Properties>

    <upd:LocalizedPropertiesCollection>

        <upd:LocalizedProperties>

            <upd:Language>en</upd:Language>

            <upd:Title>Critical Update for SQL Server 2000 Desktop Engine (Windows) on Windows Server 2003 (KB829358)</upd:Title>

        </upd:LocalizedProperties>

    </upd:LocalizedPropertiesCollection>

    <upd:Relationships>

        <upd:Prerequisites>

            <upd:UpdateIdentity UpdateID="30b6a809-9ba3-4c0f-9ca3-f569d01dab11"/>

            <upd:AtLeastOne>

                <upd:UpdateIdentity UpdateID="32b55feb-b5f5-47a7-8cc2-6a095c680267"/>

                <upd:UpdateIdentity UpdateID="0d27b716-280a-42a2-864a-bcd065c162e9"/>

            </upd:AtLeastOne>

            <upd:UpdateIdentity UpdateID="3e0afb10-a9fb-4c16-a60e-5790c3803437"/>

            <upd:AtLeastOne>

                <upd:UpdateIdentity UpdateID="dbf57a08-0d5a-46ff-b30c-7715eb9498e9"/>

                 <upd:UpdateIdentity UpdateID="7f44c2a7-bc36-470b-be3b-c01b6dc5dd4e"/>

            </upd:AtLeastOne>

        </upd:Prerequisites>

    </upd:Relationships>

    <upd:ApplicabilityRules>

        <upd:IsInstalled>

            <bar:FileVersion Csidl="38" Path="Microsoft SQL Server/MSSQL$SHAREPOINT/binn/sqlservr.exe" Comparison="GreaterThanOrEqualTo" Version="2000.080.0884.00"/>

        </upd:IsInstalled>

        <upd:IsInstallable>

            <lar:And>

                 <bar:FileVersion Csidl="38" Path="Microsoft SQL Server/MSSQL$SHAREPOINT/binn/sqlservr.exe" Comparison="EqualTo" Version="2000.080.0880.00"/>

                <bar:WUv4RegKeyValue Data="{65657C59-23A8-4974-B8E0-BA04EBD04E4F}" Value="ProductCode" Key="HKEY_LOCAL_MACHINE" Subkey="SOFTWARE/Microsoft/Microsoft SQL Server/Sharepoint/Setup"/>

                <bar:WUv4RegKeyValue Data="2052" Value="Language" Key="HKEY_LOCAL_MACHINE" Subkey="SOFTWARE/Microsoft/Microsoft SQL Server/SharePoint/MSSQLServer/CurrentVersion"/>

                <lar:Not>

                    <lar:Or>

                        <bar:RegKeyExists Key="HKEY_LOCAL_MACHINE" Subkey="SOFTWARE/Microsoft/Microsoft SQL Server/SHAREPOINT/Tracking/Shortcuts"/>

                        <bar:FileExists Csidl="38" Path="Microsoft SQL Server/MSSQL$SHAREPOINT/sqlsunin.ini"/>

                        <bar:FileExists Csidl="38" Path="Microsoft SQL Server/MSSQL$SHAREPOINT/uninst.isu"/>

                    </lar:Or>

                </lar:Not>

            </lar:And>

         </upd:IsInstallable>

    </upd:ApplicabilityRules>

    <upd:Files>

        <upd:File Digest="nBaLoGVnv7N0xq5Fs37K22/qDm4=" DigestAlgorithm="SHA1" FileName="SQL2000-KB829358-8.00.0884-CHS.exe" Size="3320008" Modified="2003-12-17T23:19:11.8170000-08:00"/>

    </upd:Files>

    <upd:HandlerSpecificData xsi:type="cmd:CommandLineInstallation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <cmd:InstallCommand RebootByDefault="false" DefaultResult="Failed" Arguments="/Q /C:&quot;msiexec /p sqlrun16.msp REINSTALL=ALL REINSTALLMODE=OMUS /l*v /WMSDEHotfix.log /q&quot;" Program="SQL2000-KB829358-8.00.0884-CHS.exe">

            <cmd:ReturnCode Code="3010" Reboot="true" Result="Succeeded"/>

            <cmd:ReturnCode Code="0" Reboot="false" Result="Succeeded"/>

        </cmd:InstallCommand>

    </upd:HandlerSpecificData>

</upd:Update>'

 

想取到如下结果:

< upd: Relationships >

        < upd: Prerequisites >

            < upd: UpdateIdentity UpdateID = "30b6a809-9ba3-4c0f-9ca3-f569d01dab11" />

            < upd: AtLeastOne >

                < upd: UpdateIdentity UpdateID = "32b55feb-b5f5-47a7-8cc2-6a095c680267" />

                < upd: UpdateIdentity UpdateID = "0d27b716-280a-42a2-864a-bcd065c162e9" />

            </ upd: AtLeastOne >

            < upd: UpdateIdentity UpdateID = "3e0afb10-a9fb-4c16-a60e-5790c3803437" />

            < upd: AtLeastOne >

                < upd: UpdateIdentity UpdateID = "dbf57a08-0d5a-46ff-b30c-7715eb9498e9" />

                < upd: UpdateIdentity UpdateID = "7f44c2a7-bc36-470b-be3b-c01b6dc5dd4e" />

            </ upd: AtLeastOne >

        </ upd: Prerequisites >

    </ upd: Relationships >

 

查询:

select @xml . query ( 'declare namespace upd="http://schemas.microsoft.com/msus/2002/12/Update";

//upd:Relationships

' )

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值