我不知道如何为Android中的资源获取正确的XML结构。
我已经将recepies.xml保存到values文件夹中,并希望对其进行解析。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recepies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<recepie name="recepie1">
<item></item>
<NumberOfPersons>1</NumberOfPersons>
<Ingredients>
<string></string>
<string></string>
</Ingredients>
<Preparation></Preparation>
<Energy>342</Energy>
<Protein>8</Protein>
<RecipeCategory>3</RecipeCategory>
</recepie>
但是,我收到或“无效的开始标签”,
如果我格式化时没有像这样的收件人标签:
<?xml version="1.0" encoding="UTF-8" standalone="yes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?>
我明白了,不再允许使用伪属性。
如果我只使用这个:
<?xml version="1.0" encoding="UTF-8"?>
我知道标记格式不正确。
我想我在XML格式的基础知识中缺少一些东西,但是我不知道是什么。
最佳答案
/res/values
文件夹仅适用于android资源。您只能在这里定义这些类型的资源之一。
http://developer.android.com/guide/topics/resources/available-resources.html
如果需要自己的xml文件,请将其放在/assets
文件夹中。