수색…


통사론

  1. 특정 노드 내부 :

    {경로 대 부모} / 이름 () = '검색 문자열']

  2. 문서의 어느 곳에서나 :

    // * [name () = '검색 문자열']

매개 변수

기능 반환 값
지역 이름 () 접두사가없는 노드의 이름

비고

local-name () 결과에 접두어 (lookup name ())가 포함되어 있지 않습니다.

이름이 Light, Device 또는 Sensor 인 노드를 검색합니다.

XML

<Galaxy>
    <Light>sun</Light>
    <Device>satellite</Device>
    <Sensor>human</Sensor>
    <Name>Milky Way</Name>
</Galaxy>

XPATH

/Galaxy/*[local-name()='Light' or local-name()='Device' or local-name()='Sensor']

또는

//*[local-name()='Light' or local-name()='Device' or local-name()='Sensor']

산출

<Light>sun</Light>
<Device>satellite</Device>
<Sensor>human</Sensor>

Light가 포함 된 이름을 가진 노드를 검색하십시오.

XML

<Data>
    <BioLight>
        <name>Firefly</name>
        <model>Insect</model>
    </BioLight>
    <ArtificialLight>
        <name>Fire</name>
        <model>Natural element</model>
        <source>flint</source>
    </ArtificialLight>
    <SolarLight>
        <name>Sun</name>
        <model>Star</model>
        <source>helium</source>
    </SolarLight>
</Data>

XPATH

/Data/*[contains(local-name(),"Light")]

또는

//*[contains(local-name(),"Light")]

산출

<BioLight>
  <name>Firefly</name>
  <model>Insect</model>
</BioLight>
<ArtificialLight>
  <name>Fire</name>
  <model>Natural element</model>
  <source>flint</source>
</ArtificialLight>
<SolarLight>
  <name>Sun</name>
  <model>Star</model>
  <source>helium</source>
</SolarLight>

이름이 Star로 시작하는 노드를 찾습니다.

XML

<College>
    <FootBall>
        <Members>20</Members>
        <Coach>Archie Theron</Coach>
        <Name>Wild cats</Name>
        <StarFootballer>David Perry</StarFootballer>
    </FootBall>
    <Academics>
        <Members>100</Members>
        <Teacher>Tim Jose</Teacher>
        <Class>VII</Class>
        <StarPerformer>Lindsay Rowen</StarPerformer>
    </Academics>
</College>

XPATH

/College/*/*[starts-with(local-name(),"Star")]

또는

//*[starts-with(local-name(),"Star")]

산출

<StarFootballer>David Perry</StarFootballer>
<StarPerformer>Lindsay Rowen</StarPerformer>

공으로 끝나는 이름을 가진 노드를 찾습니다.

XML

<College>
    <FootBall>
        <Members>20</Members>
        <Coach>Archie Theron</Coach>
        <Name>Wild cats</Name>
        <StarPlayer>David Perry</StarPlayer>
    </FootBall>
    <VolleyBall>
        <Members>24</Members>
        <Coach>Tim Jose</Coach>
        <Name>Avengers</Name>
        <StarPlayer>Lindsay Rowen</StarPlayer>
    </VolleyBall>
    <FoosBall>
        <Members>22</Members>
        <Coach>Rahul Mehra</Coach>
        <Name>Playerz</Name>
        <StarPlayer>Amanda Ren</StarPlayer>
    </FoosBall>
</College>

XPATH

/College/*[ends-with(local-name(),"Ball")]

또는

//*[ends-with(local-name(),"Ball")]

산출

<FootBall>
  <Members>20</Members>
  <Coach>Archie Theron</Coach>
  <Name>Wild cats</Name>
  <StarPlayer>David Perry</StarPlayer>
</FootBall>
<VolleyBall>
  <Members>24</Members>
  <Coach>Tim Jose</Coach>
  <Name>Avengers</Name>
  <StarPlayer>Lindsay Rowen</StarPlayer>
</VolleyBall>
<FoosBall>
  <Members>22</Members>
  <Coach>Rahul Mehra</Coach>
  <Name>Playerz</Name>
  <StarPlayer>Amanda Ren</StarPlayer>
</FoosBall>

이름이 밝은 노드 찾기 (대소 문자 구분 안함)

XML

<Galaxy>
    <Light>sun</Light>
    <Device>satellite</Device>
    <Sensor>human</Sensor>
    <Name>Milky Way</Name>
</Galaxy>

XPATH

/Galaxy/*[lower-case(local-name())="light"]

또는

//*[lower-case(local-name())="light"]

산출

<Light>sun</Light>


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow