如何在 PL/SQL 过程 ORACLE 中使用 XPATH 读取 XML 中的属性值?
我有一个如下所示的 xml:
<!-- 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);
我正在使用
dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),
'//Student[@Enrolled="True"]');
This 返回我属性 Enrolled 为 true 的学生值。
我再次用来
dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),
'//Student[@Enrolled="False"]');
获取所有尚未注册的学生。
但我想知道是否有任何方法可以使用 xsl 处理器查找已注册属性的值,而不是直接给出 @Enrolled="True"
和 @Enrolled="False".
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_xslprocessor.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"
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
XPath 表达式
//Student/@Enrolled
将为您提供Enrolled
属性的所有值。XPath expression
//Student/@Enrolled
will give you all the values of theEnrolled
attribute.使用引用属性值的 XPath 表达式怎么样?
我是否遗漏了你问题的某些部分?
How about using an XPath expression referencing the attribute value?
Am I missing some part of your problem?