开发者

reading xmls with xpath

I need to read this xml to get values like "Simpson" for example,

<?开发者_开发百科xml version="1.0"?>
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Header>
        <Data Name="LastName">Simpson</Data>
        <Data Name="IdPeople">4355</Data>
        <Data Name="State" />
        <Data Name="City" />
        <Data Name="Requests">12</Data>
    </Header>
    <Body />
 </Example>

I do this frequently and want to use efficient code, maybe xpath is the best approach?? Some samples??


To get the last name, the xpath would be something like this:

/Example/Header/Data[Name='LastName']

To get the number of Requests:

/Example/Header/Data[Name='Requests']
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜