按属性值获取元素

时间:2015-11-23 12:41:41

标签: javascript regex dom xpath

我正在webservices通过Javascript发送请求,我收到的回复是这样的:

<ListOfBook>
<Book>
    <Id>ACIA-11QWTKX</Id>
    <ListOfBookUser recordcount="0" lastpage="true">
    </ListOfBookUser>
</Book>
<Book>
    <Id>ACIA-ANC0CC</Id>
    <ListOfBookUser recordcount="1" lastpage="true">
        <BookUser>
            <BookId>ACIA-ANC0CC</BookId>
            <BookName>TKSP_GLOBAL</BookName>
        </BookUser>
        </ListOfBookUser>
</Book>                             
<Book>
    <Id>ACIA-ANC0CF</Id>
    <ListOfBookUser recordcount="0" lastpage="true">
    </ListOfBookUser>
</Book>
<Book>
    <Id>ACIA-EUMCH5</Id>
    <ListOfBookUser recordcount="1" lastpage="true">
        <BookUser>
            <BookId>ACIA-EUMCH5</BookId>
            <BookName>TKSP_MADRID_CENTRO_SUR</BookName>
        </BookUser>
    </ListOfBookUser>
</Book>

正如您所看到的,<Book>有一些元素有一个孩子<BookUser>,还有其他元素没有这个孩子。

我需要一种方法来提取<Book><BookUser>孩子的元素regular expressionsDOMXpath。有什么建议吗?

0 个答案:

没有答案