- Disable validation
- Custom tags and attributes
<?php
require dirname( __DIR__ ) . '/vendor/autoload.php';
// example 4: Custom tags using add_parent_node() + add_node() with validation disabled.
$adf = ( new carmelosantana\SendADF\SendADF( 'WINDOWS-1250', '1.1' ) )
->validation( false )
->add_requestdate( '02/08/2021 10:41AM' )
->add_parent_node( 'cars', [
'Year' => 1999,
'Make' => 'Chevrolet',
'Model' => 'Blazer',
'VIN' => '2GTEK19R7V1511644',
'Stock' => 'P7286',
'Trim' => 'LT',
'Doors' => 4,
'Body' => 'SUV',
'Transmission' => 'A',
], [ 'i_want_to' => 'buy', 'status' => 'used', 'this' => 'not in spec' ] )
->add_node( 'odometer', 90000, [ 'status' => 'replaced', 'units' => 'miles'] )
->add_parent_node( 'COLORS', [
'interiorcolor' => 'lush brown',
'exteriorcolor' => 'emerald green',
'preference' => '2'
], [], true )
->close_node()
->add_parent_node( 'person' )
->add_parent_node( 'contact' )
->add_node( 'Name', 'John', [ 'part' => 'first' ] )
->add_node( 'Name', 'Doe', [ 'part' => 'last' ] )
->add_node( 'Email_Address', '[email protected]' )
->add_node( 'Cell', '393-999-3922', [ 'time' => 'morning' ] )
->close_node()
->add_parent_node( 'TimePlease', [ 'description' => 'Within 1 month' ], [], true )
->add_node( 'Words', 'Can you deliver my new car by next Thursday?' )
->close_node()
->add_parent_node( 'business' )
->add_node( 'businessname', 'Carmelo\'s Internet Outlet' )
->add_node( 'website', 'https://carmelosantana.com' )
->add_parent_node( 'talk_to_me' )
->add_node( 'my_name_is', 'Carmelo Santana', [ 'part' => 'full' ] )
->add_node( 'email', '[email protected]' )
->add_node( 'voice', '333-999-2222', [ 'when' => 'evening'] )
->add_node( 'fax', '393-991-2999', [ 'when' => 'evening'] )
->add_parent_node( 'where', null, [ 'type' => 'business' ] )
->add_node( 'street', '86 Broadway', [ 'line' => 1 ] )
->add_node( 'street', 'First Floor', [ 'line' => 2 ] )
->add_node( 'city', 'Newburgh' )
->add_node( 'state', 'NY' )
->add_node( 'zipcode', '12550-7638' )
->add_node( 'country', 'US' )
->close_node()
->close_node()
->close_node()
->add_parent_node( 'the_who' )
->add_node( 'name', 'CarPoint' )
->add_node( 'service', 'Used Car Classifieds' )
->add_node( 'url', 'http://carpoint.msn.com' )
->add_node( 'email', '[email protected]' )
->add_node( 'phone', '425-555-1212' );
echo $adf->getPrettyPrintXML();
Output
<?xml version="1.0" encoding="WINDOWS-1250"?>
<?adf version="1.1"?>
<adf>
<prospect status="new">
<requestdate>2021-02-08T10:41:00-05:00</requestdate>
<cars i_want_to="buy" status="used" this="not in spec">
<Year>1999</Year>
<Make>Chevrolet</Make>
<Model>Blazer</Model>
<VIN>2GTEK19R7V1511644</VIN>
<Stock>P7286</Stock>
<Trim>LT</Trim>
<Doors>4</Doors>
<Body>SUV</Body>
<Transmission>A</Transmission>
<odometer status="replaced" units="miles">90000</odometer>
<COLORS>
<interiorcolor>lush brown</interiorcolor>
<exteriorcolor>emerald green</exteriorcolor>
<preference>2</preference>
</COLORS>
</cars>
<person>
<contact>
<Name part="first">John</Name>
<Name part="last">Doe</Name>
<Email_Address>[email protected]</Email_Address>
<Cell time="morning">393-999-3922</Cell>
</contact>
<TimePlease>
<description>Within 1 month</description>
</TimePlease>
<Words>Can you deliver my new car by next Thursday?</Words>
</person>
<business>
<businessname>Carmelo's Internet Outlet</businessname>
<website>https://carmelosantana.com</website>
<talk_to_me>
<my_name_is part="full">Carmelo Santana</my_name_is>
<email>[email protected]</email>
<voice when="evening">333-999-2222</voice>
<fax when="evening">393-991-2999</fax>
<where type="business">
<street line="1">86 Broadway</street>
<street line="2">First Floor</street>
<city>Newburgh</city>
<state>NY</state>
<zipcode>12550-7638</zipcode>
<country>US</country>
</where>
</talk_to_me>
</business>
<the_who>
<name>CarPoint</name>
<service>Used Car Classifieds</service>
<url>http://carpoint.msn.com</url>
<email>[email protected]</email>
<phone>425-555-1212</phone>
</the_who>
</prospect>
</adf>