Re: Urgent XML DOM question in Oracle
Date: Fri, 13 Mar 2009 00:36:27 +0100
Message-ID: <49B99C7B.9050509_at_gmail.com>
Nicklas schrieb:
> Hi
>
> I have a question when I use the xmldom in a procedure.
>
> I need to have the following information in my file from the
> procedure:
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <?POSTNET SND="XXXXX001" REC="XXXX0001" MSGTYPE="XXX"?>
>
> The problem with the xmldom is that I don't know how to add the tag
> <?
> POSTNET SND="XXXXX001" REC="XXXX0001" MSGTYPE="XXX"?> to the root.
>
> Any suggestions would be very appreciated.
>
> Best regards
> Nicklas
Please, take into account, that subject URGENT is generally considered
on this newsgroup as rude. As well as multiposting - doing that you
don't increase your chance to get helpful answer, similarly by not
publishing your oracle version - especially xml functionality is subject
to change between releases.
But assuming, you are on 10gR2, you could do something like this with xmlpi.
SQL> with t as (
2 select xmltype('<?xml version="1.0" encoding="UTF-8" ?><doc/>') x from dual
3 )
4 select updatexml(x,'/doc',
5 xmlconcat(xmlpi(name "POSTNET",'SND="XXXXX001"
REC="XXXX0001" MSGTYPE="XXX"'),
6 extract(x,'/doc')) 7 ) xml
8 from t;
XML
<?xml version="1.0" encoding="UTF-8"?><?POSTNET SND="XXXXX001" REC="XXXX0001" MSGTYPE="XXX"?><doc/>
If you are on 9i, there is no xmlpi, but you could search OTN XMLDB Forum for workarounds (i have seen a couple, if i am not wrong).
Best regards
Maxim Received on Thu Mar 12 2009 - 18:36:27 CDT