enter image description here it is necessary to write data from xml to mysql

Here I sketched code in php, but for some reason the variables are empty enter image description here

xml:

Closed due to the fact that off-topic participants Dmitriy Simushev , Grundy , cheops , aleksandr barakin , user194374 1 Jul '16 at 6:18 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Dmitriy Simushev, Grundy, cheops, aleksandr barakin, Community Spirit
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • xml: <goods> <good sh = "123" name = "qwe" ed = "oopopop" cost = "123456" /> <good sh = "001" name = "asdf" ed = "zxcczxc" cost = "56742 "/> </ goods> - Martinez Toni
  • Linux? I thought only I use it alone. On the issue: you have it commented out there - user33274
  • @LenovoID he swears at this line. - Martinez Toni
  • Code and source data can not be published with screenshots. They must be in text form. - Nick Volynkin

1 answer 1

Go through entities like this:

foreach ($sxml->good as $good) { $sh = $good['sh']; $name = $good['name']; $ed = $good['ed']; $cost = $good['cost']; // Или можно в одну строчку, если последовательность аттрибутов гарантированно не меняеться // list($sh, $name, $ed, $cost) = $good->attributes(); printf("%s %s %s %s <br/>", $sh, $name, $ed, $cost); }