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
https://forums.phpfreaks.com/topic/288563-xml-and-json/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.