如何使用以下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 :(得分: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
。
只需google xpath default namespace
,这是有史以来最常见的常见问题解答。