2012-08-28 2 views
0

다음 html 태그 구조가 있습니다.마지막 노드를 제외하는 방법

<?xml version="1.0" encoding="UTF-8"?><div class="MainContentTextContainer"> 
<br/> To break the stalemate of heavy competition and low growth in the traditional orthopedic implant markets, the major orthopedic companies are turning to biologics. This white paper provides some information on this trend. Information from this White Paper was obtained from Kalorama's full market study on this market 'The World Market for Orthopedic Biomaterials SKU KLI6329663," as well as news media sources. <br/> 
<br/> 
<p> "We also feature department and global pricing for reports that we be utilized by more than one user at your company." 
</p> 
<p> 
<b>Related Reports:</b> 
</p> 
<!-- [PID:6921310] --> 
<a href="http://www.kaloramainformation.com/Global-Medical-Devices-6921310/" class="StandardLink DkBlueType">The Global Market for Medical Devices, 3rd. Edition</a> 
<br/>May 2, 2012 - KLI3873247 - $1,995.00<br/> 
<br/> 

</div> 

는 위 내 HTML 노드 structure.I에 포함 된 마지막 <p> 태그 후 노드가 포함되어 있지 않습니다 MainContentTextContainer 노드 반환 할 것입니다 '관련 보고서 :'.

//div[@class='MainContentTextContainer']/*[not(self::p[last()])] 

을하지만이 작동하지 않습니다 : 내가 XPath는 다음과 같은 사용했다

<div class="MainContentTextContainer"> 
    <br/> To break the stalemate of heavy competition and low growth in the traditional orthopedic implant markets, the major orthopedic companies are turning to biologics. This white paper provides some information on this trend. Information from this White Paper was obtained from Kalorama's full market study on this market 'The World Market for Orthopedic Biomaterials SKU KLI6329663," as well as news media sources. <br/> 
    <br/> 
    <p> "We also feature department and global pricing for reports that we be utilized by more than one user at your company." 
    </p> 
    </div> 

:

는 다음과 같이 내가 예상 출력을 원하는 의미한다. 적절한 xpath로 안내해주세요.

감사합니다. *

(//div[@class='MainContentTextContainer']/* | //div[@class='MainContentTextContainer']/text())[following-sibling::p] 
+0

의 XPath는 * 쿼리입니다 : –

답변

0

이 XPath 식

은 포함되지 다음 마지막 p와 노드를 의미 p, 뒤에있는 div 내부의 모든 텍스트와 요소 노드를 반환 XML 문서 용 언어 따라서 XML 문서에서 노드를 삭제하는 것과 같이 XML 문서를 수정할 수 없습니다. 당신이 원하는 것은 변환 (transformation) *이라고하며, XSLT를 사용하여 쉽게 달성 할 수 있습니다. XSLT 솔루션에 관심이 있으십니까?
관련 문제