2013-05-02 174 views
0

我使用xpath從xhtml/xml文件中獲取一些節點名稱。Xpath獲取多個節點名稱

我現在有這個XPath: /xhtml:html/xhtml:head/xforms:model/xforms:instance/form/*[starts-with(local-name(), 'section')]

這將讓用這樣的名稱的節點: 科1_s1_partners 部分2 - s2_strategy

以上的XPath的結果是匹配的節點,但我想爲每個匹配獲取完整節點名稱。當我使用的名稱()函數一樣 name(/xhtml:html/xhtml:head/xforms:model/xforms:instance/form/*[starts-with(local-name(), 'section')]) 然後它只返回的第一場比賽,我不知道如何做到這一點,否則..

任何偉大的想法?

謝謝!

(的XHTML/XML:)

<xhtml:html ....> 
<xhtml:head> 
    <xhtml:title>ASD-1</xhtml:title> 
    <xforms:model id="fr-form-model"> 
     <xforms:instance id="fr-form-instance"> 
      <form> 
       <section-1_s1_partners> 
        <control-304/> 
        <toggleForm>ASD</toggleForm> 
        <applicationid/> 
        <section-345> 
         <s1_kbPaAAr/> 
         <s1_kbDCCent/> 
         <s1_kbRAE/> 
        </section-345> 
        <section-s1_depDDFentGFress> 
         <address_search/> 
         <address_postcode/> 
         <address_address1/> 
         <address_address2/> 
         <address_address3/> 
         <address_city/> 
        </section-s1_departmentAddress> 
        <section-344> 
         <s1_companyPartner/> 
         <s1_companyRegistrationNumber/> 
         <s1_companyType/> 
         <s1_companySize/> 
        </section-344> 
        <section-s1_companyAddress> 
         <address_search/> 
         <address_postcode/> 
         <address_address1/> 
         <address_address2/> 
         <address_address3/> 
         <address_city/> 
        </section-s1_companyAddress> 
        <section-324> 
         <s1_plannedDate/> 
         <s1_workDescription/> 
         <s1_publicDescription/> 
         <s1_numberOfAssociates>1</s1_numberOfAssociates> 
         <s1_duration/> 
         <s1b_resubmissionYesNo/> 
         <s1_GAAGrogramNumber/> 
        </section-324> 
       </section-1_s1_partners> 
       <section-2-s2_strategy> 
        <control-4/> 
        <s2_memo_strategic/> 
        <s2_memo_problems/> 
        <s2_companyPosition/> 
        <s2_companyContribution/> 
        <s2_lackExpertise/> 
        <s2_essential/> 
        <s2_companySponsor/> 
        <s2_seekKnowledge/> 
        <s2_challenge/> 
       </section-2-s2_strategy> 

回答

0

name該功能需要一個參數,它不能把一個節點列表。您必須使用您正在使用的語言迭代節點列表。例如,在xsh中:

for /xhtml:html/xhtml:head/xforms:model/xforms:instance/form/*[starts-with(local-name(), 'section')] 
    echo name()