PHP & XML

Any ideas?

Page 1 of 1

10 Replies - 1592 Views - Last Post: 05 March 2002 - 09:09 AM Rate Topic: -----

#1 Sargant  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-November 01

PHP & XML

Posted 28 January 2002 - 04:22 PM

I've got a script which is running an XML file as its data source (i.e. to store settings).  Is it possible to allow someone to edit the file thorough an admincenter or something, and simple edit a single piece of information from the XML file instead of having to rebuild the whole tree?
Is This A Good Question/Topic? 0
  • +

Replies To: PHP & XML

#2 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: PHP & XML

Posted 28 January 2002 - 04:37 PM

Couldn't you just read the file in to a text box, edit it and print the result back to the file?
Was This Post Helpful? 0
  • +
  • -

#3 Sargant  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-November 01

Re: PHP & XML

Posted 28 January 2002 - 04:43 PM

It wouldn't be that useable for end users then though, and I want to give it a "friendly-face" like an admin control panel, or something.
Was This Post Helpful? 0
  • +
  • -

#4 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: PHP & XML

Posted 28 January 2002 - 04:49 PM

Well, you could do it node by node.  Like just print the values of every node and every varible that why they are change able and then you can label them as to what they do.  That's pretty much what ikonboard 3 does in it's admin panel.
Was This Post Helpful? 0
  • +
  • -

#5 Sargant  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-November 01

Re: PHP & XML

Posted 28 January 2002 - 04:53 PM

Umm, would I need a different type of parser then? The only parser I'm used to is the SAX parser...
Was This Post Helpful? 0
  • +
  • -

#6 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: PHP & XML

Posted 28 January 2002 - 05:10 PM

And we have moved to the above my head level. Sorry, I've never used XML before, I just know the very very basics.

As you can see with my other scripts, I'm new to PHP and programining in general.

Was This Post Helpful? 0
  • +
  • -

#7 Sargant  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-November 01

Re: PHP & XML

Posted 29 January 2002 - 03:28 PM

OK sorry, no problem
I posted on DevShed too and nobody seems to have a clue... time for a bit of intuitave (sic) coding methinks... :D

[edit] intuitave? inventive? in-somethingorother, I can code but i can't spell...[/edit]

(Edited by Sargant at 10:29 pm on Jan. 29, 2002)

Was This Post Helpful? 0
  • +
  • -

#8 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: PHP & XML

Posted 29 January 2002 - 04:06 PM

Well, that's one better than me, I can't spell OR code.
Was This Post Helpful? 0
  • +
  • -

#9 Sargant  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-November 01

Re: PHP & XML

Posted 29 January 2002 - 04:26 PM

Quote

Quote: from The Neoracle on 11:06 pm on Jan. 29, 2002
Well, that's one better than me, I can't spell OR code.

LOL

Together now with Uncle Rob...
c.. a.. t.. cat.
See?
Well done! ;) :D

Was This Post Helpful? 0
  • +
  • -

#10 iordy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 05-March 02

Re: PHP & XML

Posted 05 March 2002 - 07:39 AM

I cant give you any code as I'm a perl programmer, but if your config file is set up as <var name="">value</var> or something as consistent then you could load the node into a hash (or associative array - in php I think it doesn't distinguish between a normal array and an associative)

So with:<var name=”foo”>bar</var> you end up with name => value pairs and in this case an array equivalent to $array = array( ‘foo’ => ‘bar’);.

Then run a foreach loop to load each key/value pair into something like:

<tr>
 <td>foo</td><td><input type="text" name="foo" value="bar">
</tr>

and print the form.

Because every node is accounted for (with the old value and the option to change it via the input box) when the administrator submits the form just recompile all the key/value pairs into a new xml file and write to disk.

I'm sorry I cant give you any code examples but it should be straight forward enough.

(Edited by iordy at 9:43 am on Mar. 5, 2002)

Was This Post Helpful? 0
  • +
  • -

#11 The Neoracle  Icon User is offline

  • Check, check, 1, 2.
  • member icon

Reputation: 21
  • View blog
  • Posts: 4,097
  • Joined: 30-March 01

Re: PHP & XML

Posted 05 March 2002 - 09:09 AM

Yeah, that's what I was trying to say, but I didn't know how to explain it!

;D


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1