Click here to Skip to main content
15,886,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to query a large xml file for a specific element based on an attribute of that element but I have been unsuccessful. I have searched google and all examples I have found don't work. Here is the xml:

XML
<?xml version="1.0" encoding="utf-8"?>
    <OfflineSyncPackage MinimumClientVersion="5.8.0.2678" ProtocolVersion="1.0" PackageId="7e79700f-c2b3-413d-8748-cff81e1f35ee" SourceId="9c3290b2-1be0-4631-9064-bfc27bedfca0" CreationDate="2013-02-12T02:12:25Z" PackageVersion="1.1" xmlns="http://schemas.microsoft.com/msus/2004/02/OfflineSync">
        <Updates>
            <Update CreationDate="2013-02-12T18:00:00Z" DefaultLanguage="en" UpdateId="6e03d226-b005-4be7-8254-7c1760886bfd" RevisionNumber="202" RevisionId="7066195" IsLeaf="true" IsBundle="true">
                <Categories>
                    <Category Type="Company" Id="56309036-4c77-4dd9-951a-99ee9c246a94" />
                    <Category Type="Product" Id="2ee2ad83-828c-4405-9479-544d767993fc" />
                    <Category Type="ProductFamily" Id="6964aab4-c5b5-43bd-a17d-ffb4346a8e1d" />
                    <Category Type="UpdateClassification" Id="0fa1201d-4330-4fa8-8ae9-b877473b6441" />
                </Categories>
                <Prerequisites>
                    <UpdateId Id="f8c1d184-7116-498a-903e-25b17eb66bac" />
                    <UpdateId Id="59653007-e2e9-4f71-8525-2ff588527978" />
                    <UpdateId Id="0fa1201d-4330-4fa8-8ae9-b877473b6441" />
                    <UpdateId Id="2ee2ad83-828c-4405-9479-544d767993fc" />
                </Prerequisites>
            </Update>		<FileLocations>
			<FileLocation Id="ic+1hdm66VRYaIx8YMt4g7LOLQI=" Url="http://download.windowsupdate.com/msdownload/update/software/secu/2012/06/windowsxp-kb2719985-x86-deu_89cfb585d9bae95458688c7c60cb7883b2ce2d02.exe" />
			<FileLocation Id="qfvhxK9IA0F0B9yDv4iGZiO0+gE=" Url="http://download.windowsupdate.com/msdownload/update/software/secu/2012/06/msxml6-kb2721693-deu-amd64_a9fbe1c4af4803417407dc83bf88866623b4fa01.exe" />
			<FileLocation Id="IFHmvpPr8+bE3nqI1X36KXpRu+Y=" Url="http://www.download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb890175-x86-nor_2051e6be93ebf3e6c4de7a88d57dfa297a51bbe6.exe" />
			<FileLocation Id="oEiOLerAhNoywsOu9DFwVBsYFo0=" Url="http://www.download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/q318138_x86_d7b7e449a8d9dc6bb707d52ce0bfcdd70d854624.exe" />
		</FileLocations>
	</OfflineSyncPackage>


Here is my code block that doesn't work:

XML
Dim root As XElement = XElement.Load(sPackageFile)
        Dim address As IEnumerable(Of XElement) = From el In root...<Update>
                                                  Where el.@UpdateId = pID
                                                  Select el

        For Each el As XElement In address
            sPatchId = el.Attribute("UpdateId")
        Next


Any help is appreciated.
Posted

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