使用XML文件作为webview android

使用XML文件作为webview android,android,webview,xml-parsing,Android,Webview,Xml Parsing,您好,可以使用下面的xml文件在android上显示为webview吗?我不确定这是否可行,或者我是否需要一个html文件。对不起,我不知道 <?xml version="1.0" encoding="UTF-8" ?> - <Recipes> - <recipe> <category-name>Burritos</category-name> <recipe-name>Pork and Bean</re

您好,可以使用下面的xml文件在android上显示为webview吗?我不确定这是否可行,或者我是否需要一个html文件。对不起,我不知道

<?xml version="1.0" encoding="UTF-8" ?> 
  - <Recipes>
  - <recipe>
<category-name>Burritos</category-name> 
 <recipe-name>Pork and Bean</recipe-name> 
<recipe-description>Prepare this delicious and tasty recipe topped with protein rich ingredients. You can even use leftover meat while preparing this.</recipe-description> 
  <image>PorkAndBeanBurritos</image> 
 - <recipe-ingredients>
 - <![CDATA[ 
<li> 1 tbs olive oil </li>
<li> 500g pork loin steaks, thinly sliced </li>
<li> 1 red onion, halved, thinly sliced </li>
<li> 2 tsp sweet paprika </li>
<li> 2 tsp ground coriander </li>
<li> 1 x 400g can chopped tomatoes </li>
<li> 1 x 400g can red kidney beans, rinsed, drained </li>
<li> 2 tbs chopped fresh coriander </li>
<li> 8 flour tortillas </li>
<li> Shredded iceberg lettuce, to serve </li>
<li> Natural yoghurt, to serve</li>

]]> 
</recipe-ingredients>
- <recipe-steps>
- <![CDATA[ 
<li>Heat half the oil in a large non-stick frying pan over high heat. Add half the pork and cook, stirring, for 3 minutes or until golden. Transfer to a plate. Repeat with the remaining pork, reheating the pan between batches. </li>
<li>Heat the remaining oil in the pan. Add the onion and cook, stirring, for 2 minutes or until light golden. Add the paprika and coriander and cook, stirring, for 1 minute. Add the tomato and beans. Bring to the boil. Reduce heat to medium-high. Simmer for 3 minutes. </li>
<li>Return the pork to the pan. Simmer for 1 minute or until heated through. Remove from heat. Stir in the coriander. </li>
<li>Spoon a little of the pork mixture along the centre of each tortilla. Top with the lettuce and a dollop of yoghurt. Roll up to enclose the filling. Serve.</li>

 ]]> 
</recipe-steps>
 </recipe>

}

你试过什么了吗?您是否可以展示一些代码或策略,如何将此XML转换为Web视图,以便我们可以帮助您?请参阅上面的编辑。非常感谢。我试图寻找解决办法,但我似乎找不到任何答案。你到底在期待什么?WebView真的不知道如何呈现随机XML。我想在我的活动中将其显示为网页。。。我应该创建一个html文件吗?将其转换为JSON,并查看可以读取和呈现它的javascript JSON库。
 public class Instructions extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    WebView webview = (WebView) findViewById(R.id.myWebView);
    webview.setWebViewClient(new Instructions(this));
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("recipelistlite.xml");
}