php - how to insert data inside tag XML -


i want create dynamic tags in xml using php

like : <wsse:username>fqsuser01</wsse:username>

the main thing want tags change value inside ---> "wsse" (like value)

what need do? create xml file wite php?

thanks,

for purpose can use xmlwriter example (another option simplexml). both option in php core third party libraries aren't needed. wsse namespace - more them can read here
i share example code:

<?php  //create new xmlwriter object $xml = new xmlwriter();  //using memory string output $xml->openmemory();  //set indentation true (if false xml written on 1 line) $xml->setindent(true); //create document tag, can specify version , encoding here $xml->startdocument();  //create element $xml->startelement("root");  //write element $xml->writeelement("r1:id", "1"); $xml->writeelement("r2:id", "2");  $xml->writeelement("r3:id", "3"); $xml->endelement(); //end element //output xml  echo $xml->outputmemory();  ?> 

result:

<?xml version="1.0"?> <root>  <r1:id>1</r1:id>  <r2:id>2</r2:id>  <r3:id>3</r3:id> </root> 

Comments