2016-10-13 5 views
1

私はxmlを次ていますXquery:Javaを使用して複数のデータ要素を返すか?

<Products> 
    <Product> 
     <name>Sample name</name> 
     <attribute id="sampleid" location="sampleLocation" type="sampleType"/> 
     <price>12345</price> 
    </product> 
</Products> 

私は与えられた名前(常に一意)のために、このXMLから次のデータを返すことができます方法:

1. location (e.g. "sampleLocation") 
2. type (e.g. "sampleType") 
3. price (e.g. 12345 

私は現在、個別に各を照会することができていますは値を返すが、複数の値を一緒に返す構文は不明です。位置のための個々のクエリの

例:

ResourceSet resourceSet = service.query(
         format("//Products/Product[name='%s']" + 
             "/attribute/@Location/string()" 
           , StringEscapeUtils.escapeXml(journey_Name) 
         )); 

上記のクエリは、返されます。 "sampleLocationを"。あなたのJavaアプリに3つの文字列の順序を返す方法

/Products/Product/(string(attribute/@location), string(attribute/@type), string(price)) 

は、使用しているのXQueryプロセッサおよびAPIに依存し、あなたが持っていない:

+1

XQueryプロセッサとはどのAPIを使用していますか? –

答えて

1

は、次のクエリでは、3つの文字列のシーケンスを返します私たちに語った。

関連する問題