Hello,
I have extracted details from an XML document into PHP then into MySql.
I have written the following code to get the XML into PHP:
when this displays the XML is will show the following text on the page:PHP Code:$xmlDoc = new DOMDocument();
$xmlDoc->load( 'cdocument-2012-03-03.xml' );
///// THIS IS AN EVENT TAG //////
$searchNode = $xmlDoc->getElementsByTagName( "Event" );
foreach( $searchNode as $searchNode )
{
$valueEvent = $searchNode->getAttribute('VALUE');
echo "Event - $valueEvent<br /><br />";
}
Event - MyEventValueFromXMLDocument
i then have to insert it into my sql using the following insert:
HTML Code:$sql = "insert into `Conferences` (`Event`) values ('$valueEvent')";
$perform_insert = mysql_query($sql) or die("<b>Data could not be entered</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error())
This all works perfectly, but... in my XML file i hold about 300 different XML values to the same tags e.g.
<Basic-Information>
<The-Conference-ID value="THE ID 1" />
<This-Conference-ID value="THIS ID 1" />
<Subject value="THIS SUBJECT 1" />
</Basic-Information>
<Basic-Information>
<The-Conference-ID value="THE ID 2" />
<This-Conference-ID value="THIS ID 2" />
<Subject value="THIS SUBJECT 2" />
</Basic-Information>
<Basic-Information>
<The-Conference-ID value="THE ID 2" />
<This-Conference-ID value="THIS ID 2" />
<Subject value="THIS SUBJECT 2" />
</Basic-Information>
So, my question is: how can i make my xml create a new table row for the next set of information as at the min it just overwrites it.
row 1:
<Basic-Information>
<The-Conference-ID value="THE ID 1" />
<This-Conference-ID value="THIS ID 1" />
<Subject value="THIS SUBJECT 1" />
</Basic-Information>
row 2:
<Basic-Information>
<The-Conference-ID value="THE ID 2" />
<This-Conference-ID value="THIS ID 2" />
<Subject value="THIS SUBJECT 2" />
</Basic-Information>
.......
Please note I'm also using "foreach( $searchNode as $searchNode )" in the PHP, not sure if this will need changing?
Hope this all makes sense
Many Thanks

