1

XSLTについて疑問があります。XPATH 経由でタグの値を取得しようとしていますが、どうすればよいかわかりません。

このXPTAHでアクセスしようとしています:

<xsl:copy-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;C&apos; and ./@id=&apos;atom1&apos;]/*/Table1/Nombre">

しかし、それは不可能です。

私もコードで試しました:

<xsl:copy-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;C&apos; and ./@id=&apos;atom1&apos;]/DescargarFicheroPendienteResponse/DescargarFicheroPendienteResult/Table1/Nombre">

問題はタグだと思います:

これは XML の例です。

<Payload Role="C" id="atom1" statusNo="0" statusMsg="success" reference="atom2" payload="atom2" calltype="solicit response (call/reply)" adapter="WSAS">  
    <http.header>  
        <http.header.info id="X-AspNet-Version" value="2.0.50727"/>  
        <http.header.info id="Date" value="Wed, 24 Jul 2013 10:23:53 GMT"/>  
        <http.header.info id="Content-Length" value="494"/>  
        <http.header.info id="MicrosoftOfficeWebServer" value="5.0_Pub"/>  
        <http.header.info id="Content-Type" value="text/xml; charset=utf-8"/>  
        <http.header.info id="Server" value="Microsoft-IIS/6.0"/>  
        <http.header.info id="X-Powered-By" value="ASP.NET"/>  
        <http.header.info id="Cache-Control" value="private, max-age=0"/>  
    </http.header>  
    <DescargarFicheroPendienteResponse xmlns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
        <DescargarFicheroPendienteResult>  
            <NewDataSet xmlns="">  
                <Table1>  
                    <Nombre>0</Nombre>  
                    <Contenido/>  
                </Table1>  
            </NewDataSet>  
        </DescargarFicheroPendienteResult>  
    </DescargarFicheroPendienteResponse>  
</Payload>  

誰でも私を助けることができますか?

ありがとう

4

1 に答える 1

1

これを XML で指定すると、次のようになります。

<DescargarFicheroPendienteResponse xmlns="http://tempuri.org/" ....>  
    <DescargarFicheroPendienteResult>  
        <NewDataSet xmlns="">
            <Table1>  

XPath 式

vpf:Payload[....]/DescargarFicheroPendienteResponse/
   DescargarFicheroPendienteResult/Table1/Nombre

間違いなく機能しません-まず、XML ではあなたの要素DescargarFicheroPendienteResponseDescargarFicheroPendienteResult要素はhttp://tempuri.org/名前空間にあるため、それをスタイルシートのプレフィックス (例: xmlns:t="http://tempuri.org/") にマップし、XPath でそのプレフィックスを使用する必要があります。次に、. のNewDataSet上に要素がありTable1ます。

vpf:Payload[....]/t:DescargarFicheroPendienteResponse/
    t:DescargarFicheroPendienteResult/NewDataSet/Table1/Nombre
于 2013-07-24T11:21:37.307 に答える