2011-03-15 3 views
0

XSLT를 사용하여 XML의 일부 노드를 검색하는 경우 노드에 네임 스페이스가 있으면 문제가 발생합니다.

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <SOAP-ENV:Body> 
     <rpc:ConQueryByExampleResponse 
      xmlns:rpc="http://siebel.com/asi/"> 
      <SiebelMessage> 
       <ListOfContactInterfaceMobile 
        xmlns="http://www.siebel.com/xml/Contact%20Interface%20Mobile"> 
        <Contact> 
         <FirstName>Siebel</FirstName> 
         <JobTitle>Sys Admin</JobTitle> 
         <LastName>Administrator</LastName> 
         <PersonUId>0-1</PersonUId> 
         <PersonalContact>Nva</PersonalContact> 
         <PrimaryOrganization>dga</PrimaryOrganization> 
        </Contact> 
        <Contact> 
         <FirstName>xyz</FirstName> 
         <JobTitle>Sn</JobTitle> 
         <LastName>Admin</LastName> 
         <PersonUId>0-2</PersonUId> 
         <PersonalContact>Nar</PersonalContact> 
         <PrimaryOrganization>adfg</PrimaryOrganization> 
        </Contact> 
       </ListOfContactInterfaceMobile> 
      </SiebelMessage> 
     </rpc:ConQueryByExampleResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
+0

[PHP SimpleXML 객체에서 xpath 사용, SOAP + 네임 스페이스 (작동하지 않음 ..)] 복제 가능 (http://stackoverflow.com/questions/3864359/using-xpath-on-a-php-simplexml- object-soap-namespaces-not-working) –

답변

3
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:rpc="http://siebel.com/asi/" 
    xmlns:siebel="http://www.siebel.com/xml/Contact%20Interface%20Mobile"> 
    <xsl:template match="/"> 
     <xsl:apply-templates select=" 
      SOAP-ENV:Envelope/SOAP-ENV:Body/ 
      rpc:ConQueryByExampleResponse/SiebelMessage/ 
      siebel:ListOfContactInterfaceMobile/siebel:Contact/siebel:FirstName 
      "/> 
    </xsl:template> 
</xsl:stylesheet> 

결과가 Siebelxyz 될 것입니다 다음 XML에 네임 스페이스를 사용하여 첫 번째 이름을 검색하는 방법.

그냥 googlexpath default namespace입니다. 가장 자주 묻는 질문입니다.

+0

정답입니다. –

관련 문제