1 Reply Latest reply: Mar 28, 2013 4:00 AM by user8941550 RSS

    UPDATEXML help required

    user8941550
      Hi,

      I am trying to use updatexml in a simple example but getting Invalid Path Expression.
      drop table xml_tbl;
      
      create table xml_tbl (
      xml_msg_id integer,
      xml_msg_text xmltype
      );
      
      insert into xml_tbl values(1, '<main xmlns:ns1="Abc:SET"><ns1:id>1</ns1:id></main>');
       
      insert into xml_tbl values(1, '<main xmlns:ns1="Abc:SET"><ns1:id>2</ns1:id></main>');
      I can query this easily as:
      SELECT *
        FROM xml_tbl
       WHERE XMLEXISTS ('declare namespace ns1 = "Abc:SET";/main[ns1:id="1"]'
                        PASSING xml_msg_text)
      But when I use UPDATEXML I get the error as:
      Update xml_tbl
      set xml_msg_text = updatexml(xml_msg_text,
                                                                     'declare namespace ns1 = "Abc:SET";/main/ns1:id',
                                                                     '8')
       where xmlexists
       (  'declare namespace ns1 = "Abc:SET";/main[ns1:id="1"]' passing xml_msg_text )
      
       
      ORA-31013: Invalid XPATH expression

      Please help.