PHP - DomDocument getElementsByTagName('smth')->item($string); -


i'm using form insert data xml file. data comes input field, , don't know how can write on goodbye or bye depending on data of input field using this.

$hello = $xdoc->getelementsbytagname('b')->item($idofbtag); 

and xml

<a>     <b id="bye">         <name>john</name>     </b>     <b id="goodbye">         <name>emma</name>     </b> </a> 

domnodelist::item() takes integer argument index of item. in case 0 "bye" , 1 "goodbye".

but can use getelementbyid():

$hello = $xdoc->getelementbyid($idofbtag); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -