Hey Guys I am writing a application in PHP. One feature is that the admin can create a question for a test in the application. I want to use the users input to create an xml file and save the xml file in mysql database for later use. This is what i have so far

This is the php code that writes the xml

  $questions = array(); 
  $questions [] = array( 
  'text' => 'question info', 
  'varx' => '34', 
  'vary' => '$10000' 
  $questions [] = array( 
  'text' => 'question info', 
  'varx' => '20', 
  'vary' => "2000" 
  $doc = new DOMDocument(); 
  $doc->formatOutput = true; 
  $r = $doc->createElement( "questions" ); 
  $doc->appendChild( $r ); 
  foreach( $questions as $question ) 
  $b = $doc->createElement( "question" ); 
  $text = $doc->createElement( "text" ); 
  $doc->createTextNode( $question['text'] ) 
  $b->appendChild( $text ); 

  $varx = $doc->createElement( "varx" ); 
  $doc->createTextNode( $question['varx'] ) 
  $b->appendChild( $varx ); 
	$lrange1 = $doc->createElement( "lrange1" ); 
  $doc->createTextNode( $question['lrange1'] ) 
  $varx->appendChild( $lrange1 );

  $vary = $doc->createElement( "vary" ); 
  $doc->createTextNode( $question['vary'] ) 
  $b->appendChild( $vary ); 

  $r->appendChild( $b ); 
  echo $doc->saveXML(); 

this is the output in xml

<?xml version="1.0"?>
    <text>question info</text>
    <text>question info</text>

i want the out put to resemble this

<?xml version="1.0" encoding="ISO-8859-1"?>
       <text>You have a [x] Click-Through-Rate, The percentage of people that click on an ad they are presented with, in position 1 in Googles adspace. You have a [y] Click-Through-Rate in position 2.
			Based on these two numbers, what is your average CTR if your average position is the [z]?
			x -((x-y) * (z-1))

my goal here is to have my app get questions from a data base and randomize the variable in the question and give the ability of the admin to create new questions

Any help is greatly appreciated!!

5 Years
Discussion Span
Last Post by jaycastr

my first issue is that i cant get a value into <lrange1></lrange1>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.