Jump to content

Search the Community

Showing results for tags 'xml'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Found 8 results

  1. Hi guys , Well , I understand that XML useful for communicating data and exchange between different platforms .. I'm interesting in web development and it's technologies , can XML give special features for my job in web development that I can not get without ? I 've purchased beginning XML ,4ed (Wrox) , but it's 1000+ pages and it's know that XML is used in applications as well as for Web .. Do I need to read irrelevant materials like those or get to the part concerning with the Web ? and what is it ?
  2. Solved remove please.
  3. I have a problem with eclipse, it doesn't loads the big files. Like, i can't load my 9mb file for item stats or my 5mb file for npc drops. Is there a way to be able to open them?
  4. Okay, I know what the problem is, I just don't know how to fix it. The problem is when I create a new file my code would get everything from the player class but not the hp. And when I try to load the game I would get an error since [code]<hp>AMOUNT</hp>[/code] isn't in the xml file. I feel like and it probably is because the variable is static but if it's not static I wouldn't be able to change the value. When I create a new game/file, what the game makes: [code]<player> <username>Storm</username> <password>k</password> <attack>5</attack> <defence>1</defence> <magic>1</magic> <warrior>false</warrior> <archer>false</archer> <mage>false</mage> <rights>1</rights> </player>[/code] What it's missing: [code]<player> <username>Storm</username> <password>k</password> [COLOR="#FF0000"] <hp>100</hp>[/COLOR] <attack>5</attack> <defence>1</defence> <magic>1</magic> <warrior>false</warrior> <archer>false</archer> <mage>false</mage> <rights>1</rights> </player>[/code] Load file code: [code] public static void load(Player p) { String name = JOptionPane.showInputDialog("Please enter your username"); if(name.length() == 0) { JOptionPane.showMessageDialog(null, "Enter a name longer than 0 characters!"); load(p); } String pass = JOptionPane.showInputDialog("Please enter your password"); if(pass.length() == 0) { JOptionPane.showMessageDialog(null, "Enter a password longer than 0 characters!"); load(p); } else { try { XML playerFile = new XML("data/games/"+name+".xml"); playerFile.setByElement("player"); for(int i = 0; i < playerFile.getElements().size(); i++) { Map<String, String> element = playerFile.getElements().get(i); String username = playerFile.getStringByTag(element, "username"); p.setUsername(username); String password = playerFile.getStringByTag(element, "password"); p.setPassword(password); int hp = playerFile.getIntByTag(element, "hp"); p.setHp(hp); int attack = playerFile.getIntByTag(element, "attack"); p.setAttack(attack); int defence = playerFile.getIntByTag(element, "defence"); p.setDefence(defence); int magic = playerFile.getIntByTag(element, "magic"); p.setMagic(magic); boolean warrior = Boolean.parseBoolean(playerFile.getStringByTag(element, "warrior")); p.setWarrior(warrior); boolean archer = Boolean.parseBoolean(playerFile.getStringByTag(element, "archer")); p.setArcher(archer); boolean mage = Boolean.parseBoolean(playerFile.getStringByTag(element, "mage")); p.setMage(mage); int rights = playerFile.getIntByTag(element, "rights"); p.setRights(rights); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "Error with loading!", "Alert", JOptionPane.INFORMATION_MESSAGE); e.printStackTrace(); } } }[/code] XML stuff: [code]public class XML { private List<Map<String, String>> elements = new ArrayList<Map<String, String>>(); private BufferedReader reader; public XML(final String file) throws IOException { reader = new BufferedReader(new FileReader(file)); } public void setByElement(String name) throws IOException { String line; String endName = "</" + name +">"; name = "<" + name + ">"; while ((line = reader.readLine()) != null) { if (line.contains(name)) { Map<String, String> element = new HashMap<String, String>(); while (!(line = reader.readLine()).contains(endName)) { element.put(line.substring(line.indexOf("<") + 1, line.indexOf(">")), line.substring(line.indexOf(">") + 1, line.lastIndexOf("<"))); } elements.add(element); } } reader.close(); } public List<Map<String, String>> getElements() { return elements; } public String getStringByTag(Map<String, String> element, String name) { return element.get(name); } public long getLongByTag(Map<String, String> element, String name) { return Long.parseLong(element.get(name)); } public int getIntByTag(Map<String, String> element, String name) { return Integer.parseInt(element.get(name)); } public short getShortByTag(Map<String, String> element, String name) { return Short.parseShort(element.get(name)); } public byte getByteByTag(Map<String, String> element, String name) { return Byte.parseByte(element.get(name)); } }[/code] Player: [code] package text.game.player; public class Player { String username, password; [COLOR="#FF0000"] private static int hp = 100;[/COLOR] private int attack = 5; private int defence = 1; private int magic = 1; private boolean warrior = false; private boolean archer = false; private boolean mage = false; private int rights = 0; private Inventory inventory; /** * @return the username */ public String getUsername() { return username; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @return the password */ public String getPassword() { return password; } /** * @param password the password to set */ public void setPassword(String password) { this.password = password; } [COLOR="#FF0000"] /** * @return the hp */ public int getHp() { return hp; }[/COLOR] [COLOR="#FF0000"] /** * @param newHp the hp to set */ public void setHp(int newHp) { Player.hp = newHp; }[/COLOR] /** * @return the rights */ public int getRights() { return rights; } /** * @param rights the rights to set */ public void setRights(int rights) { this.rights = rights; } /** * @return the warrior */ public boolean isWarrior() { return warrior; } /** * @param warrior the warrior to set */ public void setWarrior(boolean warrior) { this.warrior = warrior; } /** * @return the archer */ public boolean isArcher() { return archer; } /** * @param archer the archer to set */ public void setArcher(boolean archer) { this.archer = archer; } /** * @return the mage */ public boolean isMage() { return mage; } /** * @param mage the mage to set */ public void setMage(boolean mage) { this.mage = mage; } /** * @return the attack */ public int getAttack() { return attack; } /** * @param attack the attack to set */ public void setAttack(int attack) { this.attack = attack; } /** * @return the defence */ public int getDefence() { return defence; } /** * @param defence the defence to set */ public void setDefence(int defence) { this.defence = defence; } /** * @return the magic */ public int getMagic() { return magic; } /** * @param magic the magic to set */ public void setMagic(int magic) { this.magic = magic; } public Inventory getInventory() { return inventory; } public void setInventory(Inventory inventory) { this.inventory = inventory; } } [/code] Error: [code]Item info loaded: 2 java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at text.game.managers.XML.getIntByTag(XML.java:49) at text.game.managers.FileManager.load(FileManager.java:92) at text.gui.GUI$4.actionPerformed(GUI.java:87) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$400(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)[/code]
  5. Can anyone tell me how to get this code to write into a XML file instead of a txt? [code] if (cmd[0].equals("addnpc") && player.getUsername().equals("newboy")) { try { FileWriter fstream = new FileWriter("data/npcs.txt", true); BufferedWriter out = new BufferedWriter(fstream); out.write("<npc>"); out.write("<id>"+Integer.valueOf(cmd[1])+"<id>"); out.write("<location>"); out.write("<x>"+player.getLocation().getX()+"</x>"); out.write("<y>"+player.getLocation().getY()+"</y>"); out.write("<z>"+player.getLocation().getZ()+"</z>"); out.write("</location>"); out.write("</npc>"); out.close(); player.sm("You added a NPC at X: "+player.getLocation().getX()+" Y: "+player.getLocation().getY()+" Z: "+player.getLocation().getZ()+""); } catch (IOException e) { player.sm("Could not add NPC!"); } } [/code]
  6. I want a code/snippet/script that reads xml file encoding=ISO-8859-1 and the file I am trying to read have this as source code The stuff I want is in red [code] <?xml version="1.0" encoding="ISO-8859-1" ?> <DYNAMIC_MENU> <TYPE>BUTTON_MENU</TYPE> <BUTTON> <DEFAULT_BUTTON_TEXT><![CDATA[[B][COLOR="#FF0000"]5 of 6 D&Ds[/COLOR][/B]]]></DEFAULT_BUTTON_TEXT> <BUTTON_ICON_URL><![CDATA[http://www.runescape.com/img/toolbar/icons/distractions_active.png]]></BUTTON_ICON_URL> <BUTTON_TOOLTIP>Click for more information</BUTTON_TOOLTIP> <WITH_DROPDOWN>TRUE</WITH_DROPDOWN> </BUTTON> <MENU> <MENU_ITEM> <CAPTION><![CDATA[[COLOR="#FF0000"]You can buy 16 battlestaves from Naff today[/COLOR]]]></CAPTION> <ICON_URL><![CDATA[ http://www.runescape.com/img/toolbar/icons/activities-icon-allow.png]]> </ICON_URL> <HINT><![CDATA[You can buy 16 battlestaves from Naff today]]></HINT> <DATA> <TYPE>LINK</TYPE> <LINK> <TARGET>NEW</TARGET> <URL><![CDATA[http://www.runescape.com/kbase/guid/varrock_achievement]]></URL> </LINK> </DATA> </MENU_ITEM> <MENU_ITEM> <CAPTION><![CDATA[[COLOR="#FF0000"]You can claim 64 more Hanky Points at the Thieves' Guild[/COLOR]]]></CAPTION> <ICON_URL><![CDATA[ http://www.runescape.com/img/toolbar/icons/activities-icon-allow.png]]> </ICON_URL> <HINT><![CDATA[You can claim 64 more Hanky Points at the Thieves' Guild]]></HINT> <DATA> <TYPE>LINK</TYPE> <LINK> <TARGET>NEW</TARGET> <URL><![CDATA[http://www.runescape.com/kbase/guid/buyers_and_cellars_members]]></URL> </LINK> </DATA> [/code] P.S : Please when you post this could you tell me what each line means ^_^ ?
  7. Make a new file in com > rs > io > NpcXMLHandler.java [code] package com.rs.io; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import com.rs.game.npc.NPC; import com.thoughtworks.xstream.XStream; /** * @author 'Mystic Flow <[email protected]> * */ public final class NpcXMLHandler { private NpcXMLHandler() { } private static XStream xmlHandler; static { xmlHandler = new XStream(); xmlHandler.alias("npc", NPC.class); } public static void toXML(String file, Object object) throws IOException { OutputStream out = new FileOutputStream(file); try { xmlHandler.toXML(object, out); out.flush(); } finally { out.close(); } } @SuppressWarnings("unchecked") public static <T> T fromXML(String file) throws IOException { InputStream in = new FileInputStream(file); try { return (T) xmlHandler.fromXML(in); } catch (Throwable e) { e.printStackTrace(); } finally { in.close(); } return null; } public static void setXmlHandler(XStream xstream) { xmlHandler = xstream; xmlHandler.alias("npc", NPC.class); } } [/code] Go to utils > NPCCombatdefinitionsL.java and add this method: [code] public static final void loadXMLNPCCombatDefinitions() { Logger.log("NPCCombatDefinitionsL", "Loading NPC CombatDefinitions...."); try { npcCombatDefinitions = NpcXMLHandler.fromXML(XML_PATH); } catch (Exception e) { if (e instanceof FileNotFoundException) { try { new File(XML_PATH); } catch (Exception e2) { e2.printStackTrace(); } } } Logger.log("NPCCombatDefinitionsL", "Loaded " + npcCombatDefinitions.size() + " NPC CombatDefinitions!"); } [/code] Replace your init method with this one: [code] public static void init() { loadXMLNPCCombatDefinitions(); /*if (new File(PACKED_PATH).exists()) loadPackedNPCCombatDefinitions(); else loadUnpackedNPCCombatDefinitions();*/ } [/code] Then declare this: [code] private static final String XML_PATH = "data/xml/npcCombatDefinitions.xml"; [/code] Remove the final modifier of: [code] private [COLOR="Red"]final[/COLOR] static HashMap<Integer, NPCCombatDefinitions> npcCombatDefinitions = new HashMap<Integer, NPCCombatDefinitions>(); [/code] Add these imports in NPCCombatDefinitionsL.java: [code] import java.io.FileNotFoundException; import com.rs.io.NpcXMLHandler; [/code] Then go to the lib folder and add these 2 jar files: [url]http://dl.dropbox.com/u/39511808/xpp3-[/url] [url]http://dl.dropbox.com/u/39511808/xstream-1.4.1.jar[/url] Go to data and make a new directory called xml, put this file in it: [url]http://dl.dropbox.com/u/39511808/npcCombatDefinitions.xml[/url] For people who want the npccombatdefs in a zip file, here you go: [url]http://dl.dropbox.com/u/39511808/npcCombatDefinitions.zip[/url] There are 1971 combat defs in it so, have fun! Credits: Mystic Flow erica (for the npcCombatDefinitions.xml file) @R-S
  8. novalfye

    .XML and .Bin

    how to i convert xml to .bin like item defs for 614 or pack xml to bin or something like that i got 20174 itemdefs.bin from titans source but i dont know how he did it plz help