Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
XML edit via PHP

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
IM



Joined: 19 Jun 2004
Posts: 42
Location: Zagreb, Hrvatska

PostPosted: 10.03.2005 21:31    Post subject: XML edit via PHP Add user to your forum ignore list Reply with quote

OK people imam XML file ove strukture:
Code:
<?xml version="1.0" encoding="windows-1252"?>
<Protecteds version="1.031">
  <Protected>
    <Name>Ivan</Name>
    <Pass>balbla</Pass>
    <Created>2005-03-10 20:26:01</Created>
    <LastUsed>1899-12-30</LastUsed>
  </Protected>
</Protecteds>


taj bi kod PHP skripta trebala editirati tako da makne završni tag </protecteds> i doda novog usera:
Code:
<Protected>
    <Name>Maja</Name>
    <Pass>lala</Pass>
    <Created>2005-03-10 21:26:01</Created>
    <LastUsed>1899-12-32</LastUsed>
  </Protected>


Tako da bi sve to nakraju izgledalo ovako:

Code:
<?xml version="1.0" encoding="windows-1252"?>
<Protecteds version="1.031">
  <Protected>
    <Name>Ivan</Name>
    <Pass>blabla</Pass>
    <Created>2005-03-10 20:28:46</Created>
    <LastUsed>1899-12-30</LastUsed>
  </Protected>
  <Protected>
    <Name>Maja</Name>
    <Pass>lala</Pass>
    <Created>2005-03-10 20:28:51</Created>
    <LastUsed>1899-12-30</LastUsed>
  </Protected>
</Protecteds>


Znam da PHP 4 ima neke funkcije za baratanje s XML-om, ali meni u manualu ništa nije jasno, probao sam i sa brisanjem zadnjeg reda pa dodavanjem novog ali to mi se čini preneuredno! Ako već može ići pravilno, zašto ne? Ima li tko ideju kako ovo ostvariti? Možda ću morati složiti nekakav parser da bi skripta kužila s čime radi?
Back to top
View user's profile Send private message
njava
mi3.crew


Joined: 25 Aug 2003
Posts: 624
Location: Zagreb

PostPosted: 10.03.2005 23:28    Post subject: Add user to your forum ignore list Reply with quote

Postoji prekonekoliko wrappera za native php xml funkcije

na zadnjem projektu na kojem smo radili sam koristio xml_parser od Manuela Lemosa, i nisam imao nekih primjedbi.

http://www.phpclasses.org/browse/file/7.html

Proparsas input i dobijes XML strukturu u obliku array-a (malo sam modificirao da prima direktni input umjesto da cita iz fajla). Nakon toga napravis operacije koje trebas na arrayu (dodas elemente, promijenis...) i kreiras novi XML output.

Taj dio mozes raditi pjeske npr:
Code:

foreach ($array as $element) {
 echo '<tag1>'.$element['tag1'].'</tag1>';
 echo '<tag2>'.$element['tag1'].'</tag2>';
}


ili s nekim od vec postojecih (output) wrappera, ovisi vec o kompleksnosti

Postoje i drugi, mozda ispravniji pristupi, u kojima nema tog srednjeg koraka prebacivanja u array, nego radis operacije direktno na xml nodovima, ali s tim nemam puno iskustva.
Back to top
View user's profile Send private message Visit poster's website
g-style



Joined: 08 Oct 2003
Posts: 89
Location: bG

PostPosted: 10.03.2005 23:43    Post subject: Add user to your forum ignore list Reply with quote

evo josh jednog linka koji moze biti od pomoci
http://www.kirupa.com/web/xml_php_parse_intermediate.htm

_________________
GSTL | WTF7 | DNK | Svakog dana i u svakom pogledu sve sam veći psihopata!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
IM



Joined: 19 Jun 2004
Posts: 42
Location: Zagreb, Hrvatska

PostPosted: 11.03.2005 08:11    Post subject: Add user to your forum ignore list Reply with quote

g-style, mislim da će mi ovo tvoje uvelike pomoći, pogledati ću kad se vratim doma. Njava - htio sam to provesti bez upotrebe nečijeg parsera, postoji li nekakav "parser standard"? Laughing
Back to top
View user's profile Send private message
njava
mi3.crew


Joined: 25 Aug 2003
Posts: 624
Location: Zagreb

PostPosted: 11.03.2005 13:36    Post subject: Add user to your forum ignore list Reply with quote

IM wrote:
g-style, mislim da će mi ovo tvoje uvelike pomoći, pogledati ću kad se vratim doma. Njava - htio sam to provesti bez upotrebe nečijeg parsera, postoji li nekakav "parser standard"? Laughing


Quote:
Znam da PHP 4 ima neke funkcije za baratanje s XML-om, ali meni u manualu ništa nije jasno,


read again, dok ne shvatis, follow links.
Back to top
View user's profile Send private message Visit poster's website
IM



Joined: 19 Jun 2004
Posts: 42
Location: Zagreb, Hrvatska

PostPosted: 11.03.2005 17:48    Post subject: Add user to your forum ignore list Reply with quote

Eh sorry stari Embarassed čim sam vidio ono sa tutorialom sam sve ostavio postrance, javiti ću vam ako uspijem!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group