Trying to figure out how to echo out the below xml. I'm having particular trouble with the 'name'. Not sure how to handle the part= attributes? Also the code below is what I'm using currently just to try and spit out parts. I lose my returns in the comments section. Is there a way I should be doing it to hold on to that so its not a giant paragraph? My end goal is to import into mysql db, but this is a start...
Code sample I'm using:
$prospect = simplexml_load_file('sample.xml');
// get all song elements as an array
$options = iterator_to_array($prospect->prospect, false);
// output json
echo $options->customer->contact->name."<br />";
echo $options->customer->contact->email."<br />";
echo $options->customer->contact->phone."<br />";
echo $options->vehicle->year."<br />";
echo $options->customer->comments."<br />";
XML sample below:
<vehicle interest="buy" status="used">
<![CDATA[Can't read full transcript? Visit http://www.mydomain.com/admin/viewtrans.php?ref=bedff7434c1576262a98df46b9c128ae to view it
Customer is looking for a used 4 door sedan type of vehicle that will keep her within $350 for monthly payment.
Amy: May I help you find what you're looking for?
Visitor: Wondering about financing
Amy: My name is Amy. May I please have your name so I know who I'm chatting with?
Amy: Hello, Jessica. Nice to meet you! I'd be happy to help. May I know what particular vehicle are you interested in?
Jess: I would like a sedan 4 door used
Amy: Great. Are you trying to stay within a certain price range?
Jess: I have an insurance payout of $2,750 and hoping to put that on a down payment for a car that would have a max everything included monthly payment of $350
Jess: Would there be anything like that available?
Amy: Sounds good. We may have something that may work for you. I'd be glad to verify the inventory from my Internet Manager and get back to you with what we have that may interest you including the specifics so you'll have options. May I have your email address where we can forward the details to?
Amy: I appreciate that, Jessica. May I also have a phone number just in case we have immediate questions?
Amy: Thank you for the information. Before I forget, may I have the correct spelling of your last name so we can address you properly?
Jess: Is it possible to have two people on one finance?
Jess: Smith - its easier to type than it is to say
Amy: Do you mean a co-signer for you?
Jess: My common law partner and I would like to have joint ownership
Jess: Saturday 12:30-2:30 I unfortunately have a very tight schedule
Amy: Fantastic. Looking forward to see you at the dealership. I'll be forwarding this chat to my Manager as soon as we finish and rest assured that we'll be in touch. Would there be anything else I may help you today?
Jess: Nope thank you.
Amy: You're welcome. It's been nice chatting with you. If you have any further questions, please don't hesitate to chat with us again. Have a great evening, Jessica.
Jess: Thank you you as well.
<id sequence="1" source="the chat"></id>
<name part="full">Internet Department</name>
<street line="1">1234 Somewhere Court</street>
<name part="full">My Chat co</name>