Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于属性名的XML提取_Xml_Xpath - Fatal编程技术网

基于属性名的XML提取

基于属性名的XML提取,xml,xpath,Xml,Xpath,我有以下结构的xml。希望仅从以下内容中提取名称信息。我正在为此使用提取函数。但对于只提取“名称”的xml路径应该是什么?我试了各种方法。请帮助如何填写此查询 <Employee> <Basics> <Attribute Name="Scope">LOCAL</Attribute> <Attribute Name="Name">Narendra</Attribute>

我有以下结构的xml。希望仅从以下内容中提取名称信息。我正在为此使用提取函数。但对于只提取“名称”的xml路径应该是什么?我试了各种方法。请帮助如何填写此查询

  <Employee>
      <Basics>
        <Attribute Name="Scope">LOCAL</Attribute>
        <Attribute Name="Name">Narendra</Attribute>
        <Attribute Name="Id">12345</Attribute>
        <Attribute Name="Type">EMPLOYEE</Attribute>
        <Attribute Name="Revision"/>
      </Basics>
</Employee>

在xpath中,您使用谓词(
[]
)来过滤具有特定条件的元素。例如,您可以使用以下xpath获取属性值等于
“Name”
元素:

SELECT 
extract(value(N), 'Attribute/text()').getStringVal() AS Emp_Name    
FROM   Employee A,    
table(xmlsequence(extract(A.XML_INFO, '/Employee/Basics/Attribute'))) N
/Employee/Basics/Attribute[@Name="Name"]