Parsing an XML document generated from SQL via DOM

  • Hi all,

    I'm struggling a little bit with parsing an XML document generated from SQL server via XMLDOM.

    The examples I see posted on the net always show nice neat XML source documents, which are different to the output from SQL.

    ie.

    <?xml version="1.0"?>

    <brendon>

    <mytable id="209727" type="3" l_status="R" c_status="R">

    <type name="My type"/></dist_ita>

    </brendon>

    I'm trying to obtain the value of "type" via the XMLDOM object model in Java. I know this is an SQL post site, but my feeling is that this problem relates more to the output from SQL.

    Does anyone have any suggestions on where I can find some examples on this (with specific SQL generated documents), or know of any special tricks when dealing with these documents?

    thanks in advance.

  • Without a schema inline or otherwise no xml parser can determine the type for you. on your select statement, try using select * from table for xml auto, xmldata.

    Tim C.

    //Will write code for food

    One Windows to rule them all, One Windows to find them,

    One Windows to bring them all and in the darkness bind them

    In the Land of Microsoft where the Shadows lie.


    Tim C //Will code for food

  • I found an answer to my problem - I needed to refer to the attribute "type" of the element "mytable". Took a number of go's to get the result, but the XMLDOM parser finally gave me the value correctly.

  • Hi Brendon

    Even though you are programming in Java I dare say that an excellent resource for all things pertaining to the xml dom and sql server is the Microsoft Developer Network library.

    You can access it at http://msdn.microsoft.com

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

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