package games.flappybird; //Le flappybird
import java****.BufferedReader;
import java****.FileReader; //MPGH block these out, but you know what they are anyway.
import java********Exception;
public class AVSMtoXML {
public static String finalText = "";
public static void main(String[] agrs) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/data.txt"));
while (in.ready()) {
String s = in.readLine();
parse(s);
}
in.close();
System.out.println("Final string is : "+finalText);
}
public static void parse(String parse){
/* References : */
//Initial : trait const QName(PackageNamespace("", "#0"), "ACCEPTTRADE") slotid 58 type QName(PackageNamespace("", "#0"), "int") value Integer(76) end
//Final : <Packet id="CREATE" type="33"/>
/* GET THE NAME */
int start_pos = (parse.indexOf("(\"\", \"#0\"), \"")+13);
int end_pos = parse.indexOf("\") slotid");
String NAME = parse.substring(start_pos, end_pos);
/* GET THE ID */
start_pos = (parse.indexOf("value Integer(")+14);
end_pos = parse.indexOf(") end");
String ID = parse.substring(start_pos, end_pos);
/* COMPILE IT TO XML */
String FinalXML = "<Packet id=\""+NAME+"\" type=\""+ID+"\"/>";
System.out.println("! PACKET XML is "+FinalXML);
finalText += FinalXML+" ";
}
}
trait const QName(PackageNamespace("", "#0"), "FAILURE") slotid 1 type QName(PackageNamespace("", "#0"), "int") value Integer(0) end
trait const QName(PackageNamespace("", "#0"), "CREATE_SUCCESS") slotid 2 type QName(PackageNamespace("", "#0"), "int") value Integer(15) end
trait const QName(PackageNamespace("", "#0"), "CREATE") slotid 3 type QName(PackageNamespace("", "#0"), "int") value Integer(33) end
package parser;
/* Create a file on C:/ named data.txt and push this inside :
<Packet id="FAILURE" type="0"/>
<Packet id="CREATE_SUCCESS" type="81"/>
<Packet id="CREATE" type="38"/>
<Packet id="PLAYERSHOOT" type="41"/>
<Packet id="MOVE" type="58"/>
<Packet id="PLAYERTEXT" type="87"/>
<Packet id="TEXT" type="93"/>
<Packet id="SHOOT2" type="31"/>
<Packet id="DAMAGE" type="24"/>
<Packet id="UPDATE" type="21"/>
and take a look at the result
*/
import java ****. BufferedReader; //Remove the spaces jackass
import java ****. FileReader;
import java ****. IOException;
public class XMLtoHPP {
public static String finalText = "";
public static void main(String[] agrs) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/data.txt"));
while (in.ready()) {
String s = in.readLine();
parse(s);
}
in.close();
System.out.println("{ " + finalText + " }");
}
public static void parse(String parse) {
/* References : */
// Initial : <Packet id="CREATE_SUCCESS" type="81"/>
// Final : CREATE_SUCCESS = 81,
// System.out.println(parse);
if (parse.contains("<Packet id=\"")) {
// System.out.println("Countains");
} else {
System.err.println("Error.");
System.err.println("Try to remove the first and the last line of the XML.");
}
/* GET THE NAME */
int start_pos = (parse.indexOf("<Packet id=\"") + 12);
int end_pos = parse.indexOf("\" type=");
String NAME = parse.substring(start_pos, end_pos);
/* GET THE ID */
start_pos = (parse.indexOf("type=\"") + 7);
end_pos = parse.indexOf("\"/>");
String ID = parse.substring(start_pos, end_pos);
/* COMPILE IT TO XML */
String FinalXML = NAME + " = " + ID + ", ";
// System.out.println("! PACKET XML is "+FinalXML);
finalText += FinalXML + " ";
}
}
![=]](/forum/images/emotions/=].gif)

