Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

special characters is not allow in xml file in asset folder in Android

How to well formed in xml file in Asset folder in Android.org.apache.harmony.xml.ExpatParser$ParseException: At line 19, column 24:not well-formed (invalid token) at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:520) at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)

Here is xml file

<?xml version="1.0" encoding="UTF-8"?>
<menu>
   <item>
        <QNO>50</QNO>    
        <QUESTIONS>Which declaration of the main method below would allow a class to be started as a standalone program. Select the one correct answer.</QUESTIONS>
        <ANSWER>35,35</ANSWER>
        <OPTIONA>35,35</OPTIONA>
        <OPTIONB>35,40</OPTIONB>
        <OPTIONC>36,32</OPTIONC>
        <OPTIOND>None of these</OPTIOND>
        <EXPLAINATION>NONE</EXPLAINATION>       
        <QUESTIONTYPE>JAVA</QUESTIONTYPE>
    </item>
<item>
        <QNO>49</QNO>    
        <QUESTIONS>What all gets printed when the following code is compiled and run? Select the three correct answers.
 public class xyz {
   public static void main(String args[]) {
      for(int i = 0; i < 2; i++) {
         for(int j = 2; j>= 0; j--) {
            if(i == j) break;
            System.out.println("i=" + i + " j="+j);
         }
      }
   }
}</QUESTIONS>
        <ANSWER>35,35</ANSWER>
        <OPTIONA>35,35</OPTIONA>
        <OPTIONB>35,40</OPTIONB>
        <OPTIONC>36,32</OPTIONC>
        <OPTIOND>None of these</OPTIOND>
        <EXPLAINATION>NONE</EXPLAINATION>       
        <QUESTIONTYPE>JAVA</QUESTIONTYPE>
    </item>
<item>
<menu>

At line 19, column 24 =public static void main(String args[]) {for(int i = 0; i < 2; i++) {

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The code snippet contains < which is also the XML metacharacter for starting a tag.

Either replace < with &lt; or wrap the code in unparsed CDATA block:

<![CDATA[ ... ]]>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...