小编Den*_*rom的帖子

XSLT中的身份转换

我有这个源XML:

<?xml version="1.0"?>
<root>
   <item1>
      <name>test</name>
      <price>160</price>
      <stock>4</stock>
      <country>Belgium</country>
   </item1>
   <item2>
      <name>Alfa</name>

      <price>140</price>

      <stock>3</stock>

      <country>Turkey</country>
   </item2>
   <item3>
      <name>Beta</name>

      <price>110</price>

      <stock>48</stock>

      <country>Holland</country>
   </item3>
   <product id="p1">
      <name>Delta</name>

      <price>800</price>

      <stock>4</stock>

      <country>Denmark</country>
   </product>
   <product id="p2">
      <name>Golf</name>

      <price>1000</price>

      <stock>5</stock>

      <country>Germany</country>
   </product>
   <product id="p3">
      <name>Alfa</name>

      <price>1200</price>

      <stock>19</stock>

      <country>Germany</country>
   </product>
   <product id="p4">
      <name>Foxtrot</name>

      <price>1500</price>

      <stock>5</stock>

      <country>Australia</country>
   </product>
   <product id="p5">
      <name>Tango</name>

      <price>1225</price>

      <stock>3</stock>

      <country>Japan</country>
   </product>
</root>
Run Code Online (Sandbox Code Playgroud)

我希望它看起来像这样:

<?xml version="1.0"?>
<root>
   <action>
      <name>test</name>

      <price>160</price>

      <stock>4</stock>

      <country>Belgium</country>
   </action>
   <action>
      <name>Alfa</name>

      <price>140</price>

      <stock>3</stock>

      <country>Turkey</country>
   </action>
   <action>
      <name>Beta</name>

      <price>110</price>

      <stock>48</stock>

      <country>Holland</country>
   </action> …
Run Code Online (Sandbox Code Playgroud)

xml xslt

4
推荐指数
1
解决办法
6468
查看次数

try/catch之后的Java返回类型

我想从我创建的方法返回String类型的数据.Eclipse说需要在try catch块之后指定一个返回类型...当我这样做时,Eclipse然后告诉我,我需要将String数据声明为Local变量......这里出了什么问题?

private String ReadData() {
    try {
        FileInputStream fis = null;
        InputStreamReader isr = null;
        String data = null;
        fis = KVOContact.this.openFileInput("data.txt");
        isr = new InputStreamReader(fis);
        char[] inputBuffer = new char[fis.available()];
        isr.read(inputBuffer);
        data = new String(inputBuffer);
        isr.close();
        fis.close();

    } catch (IOException ioe) {
        Log.e("KVOContact", "IOError" + ioe);
    }
    return data;
}
Run Code Online (Sandbox Code Playgroud)

java android return try-catch

0
推荐指数
1
解决办法
2144
查看次数

标签 统计

android ×1

java ×1

return ×1

try-catch ×1

xml ×1

xslt ×1