jeddi
03-05-2010, 11:22 AM
Hello,
I am trying to process an xml file with simplexml_load_file()
but I notice that the tags that have hyphens in are not working.
I suspect that it's structure is not valid.
This is some of it's structure:
<product>
<id>346</id>
<name>Covered Call Calculator</name>
<description>Earn blah blah blah to maximize profits.</description>
<keywords>option options covered calls stocks </keywords>
<rank>31</rank>
<merchant-name>Mathew Merten</merchant-name>
<merchant-rank>100</merchant-rank>
<date-added>2007-11-28</date-added>
</product>
I use this code to access the tags:
foreach ($xml->xpath('/marketplace/product') as $prod) {
$sql_ins = "INSERT INTO my_temp ( seller, seller_rank, title, descrip, keywords )
VALUES
( '$prod->merchant-name', '$prod->merchant-rank', '$prod_name', $descrip', '$keywords')";
Now the last 3 tags don't work - I assume that it is because they have hyphens in the name ?
Do I need to change those hyphens to underscores to make them work ?
And what would be the best way to make the change ?
( Notice that the date also has legitimate hyphens)
Thanks.
.
I am trying to process an xml file with simplexml_load_file()
but I notice that the tags that have hyphens in are not working.
I suspect that it's structure is not valid.
This is some of it's structure:
<product>
<id>346</id>
<name>Covered Call Calculator</name>
<description>Earn blah blah blah to maximize profits.</description>
<keywords>option options covered calls stocks </keywords>
<rank>31</rank>
<merchant-name>Mathew Merten</merchant-name>
<merchant-rank>100</merchant-rank>
<date-added>2007-11-28</date-added>
</product>
I use this code to access the tags:
foreach ($xml->xpath('/marketplace/product') as $prod) {
$sql_ins = "INSERT INTO my_temp ( seller, seller_rank, title, descrip, keywords )
VALUES
( '$prod->merchant-name', '$prod->merchant-rank', '$prod_name', $descrip', '$keywords')";
Now the last 3 tags don't work - I assume that it is because they have hyphens in the name ?
Do I need to change those hyphens to underscores to make them work ?
And what would be the best way to make the change ?
( Notice that the date also has legitimate hyphens)
Thanks.
.