How to set an XML Element Value?

Jhealberrenz

New Member
I am trying to create a packet in XML format according to the Plesk API Documentation, but have rarely ever used XML and am having trouble finding the answer to this. According to the documentation the packet should look like...\[code\]<packet version="1.5.1.0"> <dns> <add_rec> <type>A</type> <host>newsome</host> <value>%lt;ip></value> </add_rec> </dns></packet>\[/code\]and so far my PHP code for creating this is setup like this, but I do not know how to actually set the text value for the elements.\[code\]function DNSCreateRequest(){ $xmldoc = new DomDocument('1.0', 'UTF-8'); $xmldoc->formatOutput = true; // <packet> $packet = $xmldoc->createElement('packet'); $packet->setAttribute('version', '1.6.2.0'); $xmldoc->appendChild($packet); // <packet/dns> $dns = $xmldoc->createElement('dns'); $packet->appendChild($dns); // <packet/dns/add_rec> $addrec = $xmldoc->createElement('add_rec'); $domain->appendChild($addrec); // add_rec elements $addrec->appendChild($xmldoc->createElement('type')); $addrec->appendChild($xmldoc->createElement('host')); $addrec->appendChild($xmldoc->createElement('value')); return $xmldoc;}\[/code\]
 
Back
Top