开发者

to retrieve some nodes of XML using XSLT, problem arises if the nodes have namespaces.!

how to retrieve the first names using namespaces in the following 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>
                开发者_StackOverflow        <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>


<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>

Result will be Siebelxyz.

Just google xpath default namespace, it's the most FAQ ever.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜