Level 5
After your $xml->startElement('...'), have you tried to call $xml->writeAttribute('attr_name', 'attr_value') ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Good day,
i'm trying to setup an xml file. I got it working but not totally.
$xml = new \XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0','UTF-8');
foreach ($dps as $key => $dp) {
$xml->startElement('entry');
$xml->startElement('tile');
$xml->text('Mail Filter');
$xml->endElement();
$xml->startElement('updated');
$xml->text('2021-04-28T08:57:46Z');
$xml->endElement();
$xml->startElement('content');
$xml->text('');
$xml->endElement();
}
$xml->endDocument();
$show_dps_list = $xml->outputMemory();
$xml = null;
but i want some extra rules in de xml file. Like this one.
<apps:property name='hasTheWord' value='[email protected]'/>
How do i create those from php? Like i did above with other elements?
thanks for the help!
Please or to participate in this conversation.