当attribute2值(使用XPath)

时间:2017-08-28 10:02:20

标签: xml xpath plsql

在这个XML示例中,我希望在attribute(显示Attr_2)时使用XPath获取Attr_1="A" str1234的值。



<ROOT>
     <ELEM_1   Attr_1 = "A"   Attr_2 = "str1234" />
     <ELEM_1   Attr_1 = "B"   Attr_2 = "str5678" />
</ROOT>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

尝试以下

/ROOT/ELEM_1[1]  ->  it will return str1234
/ROOT/ELEM_1[2]  ->  it will return str5678

OR

(/ROOT/ELEM_1)[1]  ->  it will return str1234
(/ROOT/ELEM_1)[2]  ->  it will return str5678

OR

/ROOT/ELEM_1[1]/@Attr_1  -> it will return A
/ROOT/ELEM_1[2]/@Attr_1  -> it will return B

OR

/ROOT/ELEM_1[@Attr_1='A']/@Attr_2  -> It will return str1234
/ROOT/ELEM_1[@Attr_1='B']/@Attr_2  -> It will return str5678

希望它会对你有所帮助:)。

答案 1 :(得分:0)

XPath是Student

但是如果你想在Oracle DB中做,你必须使用xmltable xmlquery

<ListBox x:Name="listStudents">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Firstname}" />
                <TextBlock Text="{Binding Lastname}" Margin="2 0 0 0" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>