XML Query

  • Tables is called Table1. Has one column called Column1. Data type is XML. Data looks as follows:

    Note: I have removed the ">" so the data would show.

    <?xml version="1.0" encoding="utf-16"?

    <Webstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:WebstoreManifestSchema.xsd"

    <Manifest Name="AvatarDBManifest"

    <Version 6.1.0046.0</Version

    </Manifest

    </Webstore

    How can I query the element Version? The desired result set is: 6.1.0046.0

  • SELECT r.value('.','VARCHAR(20)')

    FROM Table1

    CROSS APPLY Column1.nodes('/*:Webstore/*:Manifest/*:Version') AS x(r)

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Yes! Yes! Yes!

    Thanks Mark!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply