XML分解实例

来源:互联网 发布:midi键盘演奏软件 编辑:程序博客网 时间:2024/05/06 21:03

原帖:http://blog.csdn.net/htl258/archive/2010/04/14/5484583.aspx

 

declare @xml xml=

'<upd:Updatexmlns: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:PropertiesDefaultPropertiesLanguage="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>CriticalUpdate for SQL Server 2000 Desktop Engine (Windows) on Windows Server2003 (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:FileVersionCsidl="38" Path="Microsoft SQLServer/MSSQL$SHAREPOINT/binn/sqlservr.exe"Comparison="GreaterThanOrEqualTo" Version="2000.080.0884.00"/>

        </upd:IsInstalled>

        <upd:IsInstallable>

            <lar:And>

                <bar:FileVersionCsidl="38" Path="Microsoft SQLServer/MSSQL$SHAREPOINT/binn/sqlservr.exe" Comparison="EqualTo"Version="2000.080.0880.00"/>

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

                <bar:WUv4RegKeyValueData="2052" Value="Language" Key="HKEY_LOCAL_MACHINE"Subkey="SOFTWARE/Microsoft/Microsoft SQLServer/SharePoint/MSSQLServer/CurrentVersion"/>

                <lar:Not>

                    <lar:Or>

                        <bar:RegKeyExistsKey="HKEY_LOCAL_MACHINE" Subkey="SOFTWARE/Microsoft/Microsoft SQLServer/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:FileDigest="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:InstallCommandRebootByDefault="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

')

原创粉丝点击