Need help in xml

  • DECLARE @myDoc xml

    DECLARE @AppName VARCHAR(100)

    SET @myDoc = '<assembly xmlns="urn:schemas-microsoft-com:asm.v1">

    <assemblyidentity version="2.2.2.2" Appname="Application2.app">

    </assemblyidentity></assembly>'

    SET @AppName = @myDoc.value('(/assembly/assemblyidentity/@Appname)[1]', 'char(150)' )

    SELECT @AppName

    may i know what is wrong in this xml

    Every rule in a world of bits and bytes, can be bend or eventually be broken
    MyBlog About Common dialog control
    A Visualizer for viewing SqlCommand object script [/url]

  • You need a namespace declaration

    SET @AppName = @myDoc.value('declare default element namespace "urn:schemas-microsoft-com:asm.v1";

    (/assembly/assemblyidentity/@Appname)[1]', 'char(150)' )

    SELECT @AppName

    ____________________________________________________

    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
  • thanks for you assistance i am just learning now how to use xml in sqlserver please assist me, can give some link to see like this kind of stuff

    Every rule in a world of bits and bytes, can be bend or eventually be broken
    MyBlog About Common dialog control
    A Visualizer for viewing SqlCommand object script [/url]

  • Have a look here

    http://msdn.microsoft.com/en-us/library/ms345122(v=sql.90).aspx

    ____________________________________________________

    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

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

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