Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007

    Unanswered: OpenXML multiple namespaces


    I've been banging my head against this one for a while. There are examples around but I can't seem to find anything that works (or find an explanation).

    The problem: The xml document uses an imported common schema to reference common tags/objects (xmlns:cmn) but I can't seem to get openXML working with multiple namespaces. If I remove the primary namespace (emboldened in red) the SELECT returns as expected. Editing the xml document is not an option.

    Here's (a simplified version) of my code...


    DECLARE @idoc INT
    DECLARE @doc varchar (8000)

    SET @doc ='
    <?xml version="1.0" encoding="UTF-8"?>
    <LHA_DATA xmlns="" xmlns:cmn="">

    EXEC sp_xml_preparedocument @idoc OUTPUT, @doc, '<LHA_DATA xmlns:cmn="xmlns=""" />'

    SELECT *
    FROM OPENXML (@idoc, 'LHA_DATA', 2)
    WITH (LACode varchar(10) '//cmn:LACode',
    OfficeCode varchar(10) '//cmn:OfficeCode')

    EXEC sp_xml_removedocument @idoc


    Any help greatly received!!!!

  2. #2
    Join Date
    Nov 2007

    Problem Solved


    My continued searching eventually proved fruitful . Anyone who stumbles on this with the same problem may find the following link useful.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts