Jump to content

XML and Json


i73

Recommended Posts

Hey guys I am Posting data over to a server file in Json and I need to know how I can add to the XML file. here is both codes. 

function validate() {
	$xml = simplexml_load_file("stock.xml");
	$sxe = new SimpleXMLElement($xml->asXML());
	
	for($i = 1; $i < 801; $i++)
	{
		$newItem->addChild("name" , "null");
	}
	
	$sxe->asXML("stock.xml");
	echo $sxe->asXML();
	
    $response = $_POST;

    $response["items"] = "Test output";
    $response["description"] = "test 42 ";
    
    $response["json"] = json_encode($response);
    echo json_encode($response);
}

The red text is what I want this json script to do. Do I have to return back to my form to add to the XML file? Can json add to a xml file on its own? Thanks for your time! have a good day!  

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.