Hello I want to send xml values to a database I just created, here is the xml file


<record>
<name>tcpmux</name>
<protocol>tcp</protocol>
<xref type="person" data="Mark_Lottor"/>
<description>TCP Port Service Multiplexer</description>
<number>1</number>
</record>
<record>
<name>tcpmux</name>
<protocol>udp</protocol>
<xref type="person" data="Mark_Lottor"/>
<description>TCP Port Service Multiplexer</description>
<number>1</number>
</record>

I've got 4 columns in my database:- ServiceName, PortNumber, TransportProtocol and Description and I need to send the name, protocol, description and number of each record to my database. I'm new to XML so your help will be highly appreciated.


I was able to print the data onto my screen for viewing.

<?php

$xml = simplexml_load_file('C:\view-source www.iana.org assignments service-names-port-numbers service-names-port-numbers.xml')
or die("Could Not Open The TEXT File<hr /> ");

foreach($xml->children() as $child)
{
foreach($child->children() as $young)
{
echo $young->getName() . ": " . $young . "<br />";
}

echo "<br />";

}

Now all I need is to send the records to MySQL.
Thanks in advance!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.