私は xml フィードからアイテム (この場合は製品) を取得する小さな PHP を作成しました。simplexml_load_file を使用して、フィードのさまざまな部分を変数に割り当てます。
それはうまく機能しており、結果をcsvファイルに出力しています。私が抱えている問題は、xml の項目の一部が html 記述であり、改行文字が含まれていることです。これらを新しい行と見なすため、これは csv を壊しています。
これを解決するために、csv の各行に行末文字列を追加し、説明からすべての \n\r を削除してから、eol 文字列を \n に置き換えて、csv を機能させる必要があります.
notepad ++で手動で実行できますが、phpで試してみるとうまくいかないようです。
以下は私が試したコードですが、これまでにこれを行ったことがないため、何かを台無しにした可能性があり、機能していないようです。結果の csv にはまだ元の改行があり、eol 文字列はまだそこにあります。
//Get The Short and Long Descriptions from the $_item in the XML
$short_Description = $_item->short_description;
$description = $_item->description;
//OK now we need to firstly remove all the \n\r \n \r from the descriptions and once that's done replace "FEOL," with \n. Easy!
// Lets strip the LF and CR from the descriptions
$new_Line = array('\n\r', '\n', '\r');
$replace = '';
$short_Description = str_replace($new_Line, $replace, $short_Description);
$description = str_replace($new_Line, $replace, $description);
// OK now we have one big long line lets add the CR or maybe LF back at the end of each line where we've put the FEOL place holder
$eol = 'FEOL,';
$replace = '\r';
$short_Description = str_replace($eol, $replace, $short_Description);
$description = str_replace($eol, $replace, $description);
彼らが私が行方不明であることが明らかな何かがあるのか 、それとも私がすべて間違っているのか疑問に思っています。どんな助けでも大歓迎です。ナイジェル