2017-04-11 2 views
0

minOccur = "1"인 노드를 선택하려는 XML이 있지만 모든 자식 노드에는 이러한 속성이 없습니다.XPATH : 특정 속성이있는 노드를 선택하고 자식 노드에 특정 속성이 없습니다.

내 XPATH :

//xnode[@type="parent" and @minOccurs="1" and ./child[not(@minOccurs)] and ./child[not(@or)] and ./not(ors) ] 

XML : ID가 = "7"반환하지만 두 노드가 반환됩니다 밝혀졌다 : 만 두 번째 노드를 기대

<root> 
<xnode type="parent" id="1" name="Date" maxOccurs="1" minOccurs="1"> 
    <Othertags id="2" language="FR" name="Date"/> 
    <child id="3" name="dateone" maxOccurs="1" value="DONE"> 
     <def id="4" language="EN" value="this is date one"/> 
    </child> 
    <child id="5" name="datetwo" maxOccurs="1" minOccurs="1" value="DTWO"> 
     <def id="6" language="EN" value="this is date two"/> 
    </child> 
</xnode> 
<xnode type="parent" id="7" name="Time" maxOccurs="1" minOccurs="1"> 
    <Othertags id="8" language="FR" name="time"/> 
    <child id="9" name="timeone" maxOccurs="1" value="TONE"> 
     <def id="10" language="EN" value="this is time one"/> 
    </child> 
    <child id="11" name="timetwo" maxOccurs="1" value="TTWO"> 
     <def id="12" language="EN" value="this is time two"/> 
    </child> 
</xnode> 
</root> 

. XPath에 무엇이 잘못 되었습니까? 고마워,

답변

3

나는 으로 노드를 선택하고 싶지만 모든 자식 노드에는 그러한 속성이없는 XML이 있습니다.

난 당신 말은 생각 :

//xnode[@type="parent" and @minOccurs="1" and not(child/@minOccurs)] 

not(child/@minOccurs) 의미 : ". @minOccurs 속성을 가진 자식이 없다"

무엇이 child[not(@minOccurs)]의 의미 : "@minOccurs 속성이없는 하위가 있습니다."

+0

예, 훌륭합니다! – dellair

관련 문제