#r #xml
#r #xml
Вопрос:
У меня есть XML-файл с огромным количеством узлов. Каждый подузел (//item/sizes/size) должен получить соответствующий подузел (//item/number). Вот пример кода:
<item>
<itemtype>A</itemtype>
<number>200379084</number>
<supplier>
<id>1091</id>
<name>Brand 1</name>
</supplier>
<sizes>
<size>
<sizeid>2</sizeid>
<sizebarcode>116</sizebarcode>
<sizeshort>116</sizeshort>
<sizelong> 116</sizelong>
<UmgerechneteGG/>
<ean>643345344363628</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>3</sizeid>
<sizebarcode>128</sizebarcode>
<sizeshort>128</sizeshort>
<sizelong> 128</sizelong>
<UmgerechneteGG/>
<ean>64334534543363635</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>4</sizeid>
<sizebarcode>140</sizebarcode>
<sizeshort>140</sizeshort>
<sizelong> 140</sizelong>
<UmgerechneteGG/>
<ean>64334534563642</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>5</sizeid>
<sizebarcode>152</sizebarcode>
<sizeshort>152</sizeshort>
<sizelong> 152</sizelong>
<UmgerechneteGG/>
<ean>6438345359</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>6</sizeid>
<sizebarcode>164</sizebarcode>
<sizeshort>164</sizeshort>
<sizelong> 164</sizelong>
<UmgerechneteGG/>
<ean>64334553666</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>7</sizeid>
<sizebarcode>176</sizebarcode>
<sizeshort>176</sizeshort>
<sizelong> 176</sizelong>
<UmgerechneteGG/>
<ean>643834553473</ean>
<stock>0</stock>
<stockperstore/>
</size>
</sizes>
</item>
<item>
<itemtype>A</itemtype>
<number>200379086</number>
<supplier>
<id>4140</id>
<name>Brand 2</name>
<sizes>
<size>
<sizeid>2</sizeid>
<sizebarcode>116</sizebarcode>
<sizeshort>116</sizeshort>
<sizelong> 116</sizelong>
<UmgerechneteGG/>
<ean>57234342233804</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>3</sizeid>
<sizebarcode>128</sizebarcode>
<sizeshort>128</sizeshort>
<sizelong> 128</sizelong>
<UmgerechneteGG/>
<ean>5713434323811</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>4</sizeid>
<sizebarcode>140</sizebarcode>
<sizeshort>140</sizeshort>
<sizelong> 140</sizelong>
<UmgerechneteGG/>
<ean>5723432128</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>5</sizeid>
<sizebarcode>152</sizebarcode>
<sizeshort>152</sizeshort>
<sizelong> 152</sizelong>
<UmgerechneteGG/>
<ean>513434323835</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>6</sizeid>
<sizebarcode>164</sizebarcode>
<sizeshort>164</sizeshort>
<sizelong> 164</sizelong>
<UmgerechneteGG/>
<ean>5723423423242</ean>
<stock>0</stock>
<stockperstore/>
</size>
<size>
<sizeid>7</sizeid>
<sizebarcode>176</sizebarcode>
<sizeshort>176</sizeshort>
<sizelong> 176</sizelong>
<UmgerechneteGG/>
<ean>572342323459</ean>
<stock>0</stock>
<stockperstore/>
</size>
</sizes>
</item>
</products>
Добавьте конец, я хотел бы получить в RStudio фрейм данных со столбцами «sizeshort», «ean», «stock» (// item/ sizes / size) и number (// item/ number).
Например:
ID EAN Stock Number
7 572342323459 0 200379086
6 5723423423242 0 200379086
5 513434323835 0 200379086
Большое спасибо за вашу помощь.