Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2010, 09:28 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
savexml/loadxml

Can anyone explain the var formatting that these two functions use? I couldn't figure out how to use savexml, so I created a template xml and used loadxml to echo it, and apparently it uses an array?

XML file:
PHP Code:
<?xml version="1.0"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>
temp.obj.loadxml("test.xml");
echo(obj);
PHP Code:
"""Tove,"",""Jani,"",""Reminder,"",""""""Don't forget me this weekend!"""","""
As you can see, it doesn't include the 'to', 'from' and so on. However, if I obj.savexml("test2.xml"), it maintains that format. I just don't know where and how it's storing it...
Reply With Quote
  #2  
Old 01-21-2010, 09:57 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Okay, seems the format is:
obj[0].name = "note";
obj[0][0].name = "to";
obj[0][1].name = "from";
obj[0][2].name = "heading";
obj[0][3].name = "fbody";
obj[0][x][0] = "text"

So ya...
Reply With Quote
  #3  
Old 01-21-2010, 04:20 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
can you not do..

echo(obj.note.to.value); ?
__________________
Quote:
Reply With Quote
  #4  
Old 01-21-2010, 07:35 PM
Immolate Immolate is offline
Indigo
Join Date: Dec 2009
Posts: 322
Immolate is on a distinguished road
Quote:
Originally Posted by fowlplay4 View Post
can you not do..

echo(obj.note.to.value); ?
Doesn't seem like it when I tested it.
Reply With Quote
  #5  
Old 01-21-2010, 08:08 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Generating xml:

PHP Code:
temp.xml "";
with (temp.xml.addArrayMember("friends")) {
  for (
temp.plallplayers) {
    
with (addArrayMember("friend")) {
      
addArrayMember("account").addArrayMember("text") = temp.pl.account;
      
addArrayMember("nick").addArrayMember("text") = temp.pl.nick;
    }
  }
}
player.sendToClient("friends"temp.xml.savexmltostring()); 
Reading XML:
PHP Code:
temp.xml.loadxmlfromstring(data);
if (
temp.xml.size() >= && temp.xml[0].name=="friends") {
  for (
temp.i=0temp.i<temp.xml[0].size(); temp.i++) {
    if (
temp.xml[0][temp.i].name=="friend") {
      echo(
"account: " temp.xml[0][temp.i].getArrayMember("account").text);
      echo(
"nick: " temp.xml[0][temp.i].getArrayMember("nick").text);
    }
  }

You can also use node attributes, there are some small things to keep care of though, "name" will be renamed to "xmlname", and "text" will automatically hold the first "text" attribute.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.