You can use XMLTable with an Xpath that targets the Kod=N nodes, then walks back up the tree to get the doc_num; this version assumes your original value is a string:
select distinct xml.doc_num, xml.x
from your_table t
cross apply xmltable (
'/main/item/Dok[@Kod="N"]'
passing xmltype(t.your_xml)
columns doc_num number path './../../@doc_num',
x number path '@X'
) xml
DOC_NUM X
------- -
99 1
99 4
99 5
db<>fiddle
If your original value is already XMLType then walking back up the tree doesn't work as expected - not sure if that's a bug but seems to happen in 11gR2 and 18c at least. You can work around that by converting to a string and back:
select distinct xml.doc_num, xml.x
from your_table t
cross apply xmltable (
'/main/item/Dok[@Kod="N"]'
passing xmltype(t.your_xml.getclobval())
columns doc_num number path './../../@doc_num',
x number path '@X'
) xml
DOC_NUM X
------- -
99 1
99 4
99 5
db<>fiddle
I've just noticed you tagged this for Oracle 11g... so cross apply isn't available, and walking back up the tree doesn't work either; neither does filtering on the child attribute name. So you can do this instead, with two levels of XMLTable:
select distinct xml1.doc_num, xml2.x
from your_table t
cross join xmltable (
'/main'
passing xmltype(t.your_xml)
columns doc_num number path '@doc_num',
doks xmltype path 'item/Dok'
) xml1
cross join xmltable (
'/Dok'
passing xml1.doks
columns kod varchar2(1) path '@Kod',
x number path '@X'
) xml2
where xml2.kod = 'N'
DOC_NUM X
------- -
99 1
99 4
99 5
which works in 11g with a string or with an XMLType source.