2014-04-05 2 views
0

나는 경험이 풍부한 개발자이지만 xpath와 xslt에 초보자가되어 회사가 갑자기 구현하기로 결정했으며 누군가가 나를 도와 줄 수 있기를 바란다. 내가 가진 도전.xpath를 사용하여 선행 노드에서 텍스트를 가져 오는 방법

이 같은 XML이있는 경우 .....

<tr layoutcode="" type="categoryhead" level="2" 
    <td colname="caption">Alex</td>  (a) 
</tr> 
<tr layoutcode="" type="categoryhead" level="3" 
    <td colname="caption">Miscellaneous</td> 
</tr> 
<tr layoutcode="" type="detail" level="4" 
    <td colname="caption">Something</td> 
</tr> 
<tr layoutcode="" type="detail" level="4" 
    <td colname="caption">This is a test</td> (b) 
</tr> 

... 난에 오전 (b)에, 내가 얻는 방법에서 텍스트를 얻을 노드의 테스트입니다 ' (a) ie 'Alex'?

내가 아는 전부는 'type'= 'categoryhead'및 'level'= 2의 속성을 가진 첫 번째 앞의 'tr'노드를 찾고 그 다음 'td'자식 노드의 텍스트를 원한다는 것입니다. 변수에 할당 할 수 있도록 올바른 xpath 쿼리를 찾고있는 것 같습니다. 사전에

많은 감사,

+0

안녕하세요! 우리가 보여준 것을 보여줄 수 있습니까? –

답변

2

알렉스 경로 ../preceding-sibling::tr[@type = 'categoryhead' and @level = 2][1]/td[@colname = 'caption']td 요소를 선택해야합니다.

관련 문제