1

Topic: Question on xml

Kind time of days!
Prompt, please, here to a system xml

DECLARE
doc DBMS_XMLDOM.DOMDocument;
xdata XMLTYPE;
CURSOR xmlcur IS
SELECT XMLROOT (XMLELEMENT ("Podtv";
XMLATTRIBUTES ('    ' as "xmlns"
, gen_guid as "IdPodtv"
, ' NameFile ' as "ImjaFajla"
, to_char (sysdate, ' yyyy-mm-dd hh24:mi:ss') as "DataVremjaProverki");
XmlElement ("RezProverki",
XMLATTRIBUTES (' 01 ' as "KodRezProverki"
, ' Ok ' as "Explanation")
)
), version ' 1.0"encoding =" windows-1251 ')
FROM dual;
BEGIN
OPEN xmlcur;
LOOP
FETCH xmlcur INTO xdata;
EXIT WHEN xmlcur%NOTFOUND;
dbms_output.put_line (xdata.getClobVal);
--doc: = DBMS_XMLDOM.NewDOMDocument (xdata);
--DBMS_XMLDOM.WRITETOFILE (doc, ' XMLDIR/NameFile.xml ');
END LOOP;
CLOSE xmlcur;
END;

Result

<? xml version = "1.0" encoding = "windows-1251"?>
<Podtv xmlns = "  " IdPodtv = "59850C52-0530-0F6C-E053-0100007FA0F3" ImjaFajla = "NameFile" DataVremjaProverki = "2017-09-19 10:51:21 AM">
<RezProverki KodRezProverki = "01" Explanation = "Ok"/>
</podtv>

Like all
But here when I save it

DECLARE
doc DBMS_XMLDOM.DOMDocument;
xdata XMLTYPE;
CURSOR xmlcur IS
SELECT XMLROOT (XMLELEMENT ("Podtv";
XMLATTRIBUTES ('    ' as "xmlns"
, gen_guid as "IdPodtv"
, ' NameFile ' as "ImjaFajla"
, to_char (sysdate, ' yyyy-mm-dd hh24:mi:ss') as "DataVremjaProverki");
XmlElement ("RezProverki",
XMLATTRIBUTES (' 01 ' as "KodRezProverki"
, ' Ok ' as "Explanation")
)
), version ' 1.0"encoding =" windows-1251 ')
FROM dual;
BEGIN
OPEN xmlcur;
LOOP
FETCH xmlcur INTO xdata;
EXIT WHEN xmlcur%NOTFOUND;
--dbms_output.put_line (xdata.getClobVal);
doc: = DBMS_XMLDOM.NewDOMDocument (xdata);
DBMS_XMLDOM.WRITETOFILE (doc, ' XMLDIR/NameFile.xml ');
END LOOP;
CLOSE xmlcur;
END;

xml '  forms without version ' 1.0"encoding =" windows-1251 ' and it is necessary to open manually a file and to add a line
<? xml version = "1.0" encoding = "windows-1251"?>
Why?

<Podtv xmlns = "  " IdPodtv = "59850C52-0530-0F6C-E053-0100007FA0F3" ImjaFajla = "NameFile" DataVremjaProverki = "2017-09-19 10:51:21 AM">
<RezProverki KodRezProverki = "01" Explanation = "Ok"/>
</podtv>

2

Re: Question on xml

Like everything, understood.
Added charset

DBMS_XMLDOM.WRITETOFILE (doc, ' XMLDIR/filename.xml ', ' windows-1251 ');

And <? xml version = "1.0" encoding = "windows-1251"?>
It was interposed in xml