Extract a substring from xml column from SQL query resultset

I have a table MYTABLE and column MYXML in Oracle 12 database. The column MYXML contains strings like below with varied lengths -

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:NodeData xmlns:ns2="http://abcd.org/xyz/schema/">
    <Head msgId="ACVF63980FGQW56123" orgId="12345" ts="2017-04-13T18:37:27+05:30" ver="1.0"/>
        <Identity id="45298" verifiedName="MFROMLA" type="TECH"/>
        <Rating name="HIGH"/>
    <Node Name="PQ" Desc="PreQualified" NodeID="2387ajdh231dqhhg21098"/>

Open in new window

I want to extract just PQ from this column values using SQL query. How do I do that? I should be able to search using Name tag if possible and extracts its value.
James BondSoftware ProfessionalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
If myxml is a CLOB or VARCHAR2 you need to wrap xmltype around the column in the passing clause.  If it is an XMLTYPE remove it and just pass myxml.

Try this:
select name from mytable, 
			xmlnamespaces ('http://abcd.org/xyz/schema/' as "ns2"),
			passing xmltype(myxml)
				name			varchar2(50)			path '@Name'

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James BondSoftware ProfessionalAuthor Commented:
Thanks for quick and perfect solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.