2009-07-10 3 views
0

이 내가 검색하기 위해 노력하고있어 일부 XML이 : 기본적으로속성을 사용하여 복잡한 XPath를 검색합니까?

<debts> 
     <section id="24" description="YYYYY"> 
     <section id="28" description="xxx"> 
      <section id="31" description="xxx"> 
       <account accountNumber="2312323" creditorId="1" amount="1200" proposedAmount="1000" percentage="11" owner="2"> 
        <foo/> 
       </account> 
      </section> 
      <section id="32" description="xxx"/> 
      <section id="33" description="xxx"/> 
     </section> 
     <section id="29" description="xxx"> 
      <section id="34" description="xxx"/> 
     </section> 
     <section id="30" description="xxx"> 
      <section id="37" description="xxx"/> 
      <section id="38" description="xxx"/> 
      <section id="39" description="xxx"/> 
     </section> 
    </section> 
</debts> 

를, 내가 뭘하려고 오전, 매우 가능성이 아니라 어떤 (섹션 YYYYY 아래에 앉아 계정의 모든 노드를 찾을 수있다 해당 레벨의 노드 만). 나는 (특히 내가 레일에 Hpricot을 사용하고 있습니다) XPath를 사용하여이 작업을 수행 할 수있는 방법

답변

3

이 시도 :

/debts//section[@description='YYYYY']//account 

http://www.bit-101.com/xpath/는 XPath 쿼리를 테스트 할 수있는 좋은 도구가 있습니다.

+0

+1 - 완전성을 위해 : 'YYYYY'에 대한 설명이있는 * 모든 * 섹션 노드 내의 모든 계정 노드를 찾습니다. – Tomalak

관련 문제