Answer the question
In order to leave comments, you need to log in
Why doesn't it display the partition ID?
<?php
$strQueryText = "/path/to/xml/file.xml";
$objXML = new CDataXML();
$objXML->Load($strQueryText);
$arData = $objXML->GetArray();
$arResult = array();
foreach ($arData['items']['#']['item'] as $arValue) {
$ar = array();
foreach ($arValue['#'] as $sKey => $sVal) {
$ar[$sKey] = $sVal[0]['#'];
}
$arResult[] = $ar;
}
$j = 0;
$sk = array();
foreach ($arResult as $qwe => $new) {
$id[$j]['guid_item'] = $new['guid_item'];
$i = 0;
while (count($new['related_folders']['guid_folder']) > $i) {
$id[$j]['guid_folder'][$i] = $new['related_folders']['guid_folder'][$i]['#'];
$i++;
}
$j++;
}
$col = count($id);
for ($i = 0; $i <= $col; $i++) {
$res = CIBlockElement::GetList(array(), array('IBLOCK_ID' => 10, 'XML_ID' => $id[$i]['guid_item'], 'SITE_ID' => "s1"));
$item = $res->Fetch();
echo "item_id: " . $item["ID"] . "<br>";
$k = 0;
$myArr = $id[$i]['guid_folder']; // не выводит
//$myArr = array('8f50834b-7f76-42c1-a019-3b3b29d93c40','37728a3a-0a97-4f16-a272-f0a8d7842d99'); // выводит
foreach ($myArr as $dope => $now) {
$fSections = CIBlockSection::GetList(
false, Array("IBLOCK_ID" => 10, "XML_ID" => $myArr[$k]), false, Array("ID"), false
);
while ($flSections = $res->getNext()) {
echo "folder_id: " . $flSections['ID'] . "<br>";
}
$k++;
}
}
//$myArr = $id[$i]['guid_folder'];
$myArr = array('8f50834b-7f76-42c1-a019-3b3b29d93c40','37728a3a-0a97-4f16-a272-f0a8d7842d99');
Answer the question
In order to leave comments, you need to log in
and he doesn't need typecasting like SimpleXML by any chance?
(string) $flSections['ID']
The problem was that there were non-existent GUIDs in the XML file.
Ahaha)))
Krch working code)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question