开发者

How to read the value of attribute in XML using XPATH in a PL/SQL procedure ORACLE?

I have an xml like the following:

<!-- XML-Code -->
indoc := '
<Students>
     <Student Enrolled = "true">
           <SID>12456</SID>
    </Student>
    <Student Enrolled = "false">
           <SID>12345</SID>
    </Student>
</Students>';
<!-- XML Code -->
indomdoc := dbms_xmldom.newDomDocument(indoc);

I am using

dbms_xsl开发者_开发百科processor.selectNodes(dbms_xmldom.makeNode(indomdoc),
                                        '//Student[@Enrolled="True"]');

This is returning me the values Of Students with attribute Enrolled as true.

and again I am using

dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),
                                        '//Student[@Enrolled="False"]');

to get all students who are not enrolled yet.

But I want to know is there any way to find the value of enrolled attribute using xsl processor, rather than directly giving like @Enrolled="True" and @Enrolled="False".


XPath expression //Student/@Enrolled will give you all the values of the Enrolled attribute.


How about using an XPath expression referencing the attribute value?

fn:data(//Student/@Enrolled)

Am I missing some part of your problem?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜