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

    Unanswered: OpenXML multiple namespaces

    Hi

    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="http://www.trs.co.uk/schema/DataShare.xsd" xmlns:cmn="http://www.trs.co.uk/schema/Common_ed.xsd">
    <Manifest>
    <cmn:senderRecipient>
    <cmn:LACode>A0000</cmn:LACode>
    <cmn:OfficeCode>0</cmn:OfficeCode>
    </cmn:senderRecipient>
    </Manifest>
    </LHA_DATA>
    '

    EXEC sp_xml_preparedocument @idoc OUTPUT, @doc, '<LHA_DATA xmlns:cmn="xmlns="http://www.trs.co.uk/schema/DataShare.xsd" http://www.trs.co.uk/schema/Common_ed.xsd" />'


    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
    Posts
    4

    Problem Solved

    Hi

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

    http://www.devnewsgroups.net/group/m...opic45014.aspx

    Cheers
    JW

Posting Permissions

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