0

I'm setting up an xml file with DOMDocument like this :

$document = new DOMDocument('1.0', 'utf-8');
$document->xmlStandalone = true;
$provider = $document->createElement( "provider" );
$j = $document->createElement( $PARAM );
$j->setAttribute( 'value', "$VALUE" );
$provider->appendChild( $j );

This works very well untill... I hit a $PARAM with square brackets in it, like :

dirProvider[0].NumberAttributes

I have tried using preg_quote(), but does not work. I have tried using htmlspecialchars(), but does not work. I have tried using createTextNode() :

$j = $document->createTextNode( $PARAM );
$j->setAttribute( 'value', "$VALUE" );
$provider->appendChild( $j );

but does not work.

An idea on how I can get these 'special' element names right ?

user2795648
  • 69
  • 1
  • 9
  • Possible duplicate of [Final solution for using regex to remove html nested tags of the same type?](https://stackoverflow.com/questions/37823200/final-solution-for-using-regex-to-remove-html-nested-tags-of-the-same-type) –  Feb 22 '18 at 11:21
  • Where is $pARAM coming from? In XML, you are more likely to create a `dirProvider` element with another element `NumberAttributes` inside in this sort of structure. – Nigel Ren Feb 22 '18 at 11:32

0 Answers0