Jump to content

How do I add an "option" node to this xml file?

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Alhazred

Alhazred

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
I have an xml file with this structure
<form>
    <fieldset>
        <field name="type" type="list" class="inputbox"
            label="Type" description="Tipo campo" 
            required="true" size="1" default="1"
        >
            <option value='text'>Text</option>
            <option value='select'>Select</option>
            <option value='radio'>Radio</option>
        </field>

        <field name="name" type="text" size="40" class="inputbox"
            label="name" description="Nome campo" 
            required="true" 
            filter="safehtml" />
...
    </fieldset>
</form>
I'm trying to use simplexml, but I don't know how to add those <option> child nodes. Could anyone help me?

Edited by Alhazred, 26 August 2011 - 04:56 AM.


#2
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
this code is html code tags

not have xml code

#3
Alhazred

Alhazred

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
Add
<?xml version="1.0" encoding="utf-8"?>
on top, this makes it an xml file now?

By the way to specify the problem, I know how to add a child node, but not how to select the correct place where to put it, in this case I need to select the <field> node with name="type" attribute.

#4
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
yes is xml :rolleyes:

#5
Alhazred

Alhazred

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
Solved.

#6
grisha

grisha

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
If you've found a solution for your problem, please leave it there for future searches :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users