Немного предыстории: есть сайт на WordPress, на нем стоит WP All Export, который делает все заказы в один файл.
У этого плагина есть свои хуки
https://www.wpallimport.com/documentation/advanced...
Необходимо разделить файл экспорта:
Orders-Export-26.xml (который можно загрузить по ссылке)
<?xml version="1.0" encoding="UTF-8"?>
<post>
<smd:order xmlns:smd="http://www.smd.com/xsd/COMMONTYPES/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" smd:DocumentType="ORDER">
<MessageHeader>
<DateOfMessage>2021-12-29 12:50:31</DateOfMessage>
</MessageHeader>
<OrderReference>322</OrderReference>
<OrderDate>2021-12-29 12:50:31</OrderDate>
<DeliveryDateRequested>2021-12-29 12:50:31</DeliveryDateRequested>
<Distributor>
<DistributorGLN>9001496000001</DistributorGLN>
</Distributor>
<OrderingParty>
<DistributorsOrderingPartyID>250002 </DistributorsOrderingPartyID>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Habr</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
<Email>67576575@yandex.ru</Email>
<Phone>+74845451564</Phone>
</OrderingParty>
<DeliveryRecipient>
<DeliveryRecipientGLN>9002804000119</DeliveryRecipientGLN>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Habr</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
</DeliveryRecipient>
<InvoiceRecipient>
<DeliveryRecipientGLN>34987349875793845</DeliveryRecipientGLN>
</InvoiceRecipient>
<ItemList>
<ListLineItem>
<OrderPosNumber>1</OrderPosNumber>
<DistributorsArticleNo>100-004</DistributorsArticleNo>
<OrderQuantity>1</OrderQuantity>
<price>6,00</price>
</ListLineItem>
</ItemList>
</smd:order>
<smd:order xmlns:smd="http://www.smd.com/xsd/COMMONTYPES/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" smd:DocumentType="ORDER">
<MessageHeader>
<DateOfMessage>2021-12-30 10:14:41</DateOfMessage>
</MessageHeader>
<OrderReference>323</OrderReference>
<OrderDate>2021-12-30 10:14:41</OrderDate>
<DeliveryDateRequested>2021-12-30 10:14:41</DeliveryDateRequested>
<Distributor>
<DistributorGLN>9001496000001</DistributorGLN>
</Distributor>
<OrderingParty>
<DistributorsOrderingPartyID>250002 </DistributorsOrderingPartyID>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Moscv</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
<Email>xnjnjzbotq@yandex.ru</Email>
<Phone>+74845451564</Phone>
</OrderingParty>
<DeliveryRecipient>
<DeliveryRecipientGLN>9002804000119</DeliveryRecipientGLN>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Moscv</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
</DeliveryRecipient>
<InvoiceRecipient>
<DeliveryRecipientGLN>34987349875793845</DeliveryRecipientGLN>
</InvoiceRecipient>
<ItemList>
<ListLineItem>
<OrderPosNumber>1</OrderPosNumber>
<DistributorsArticleNo>100-007</DistributorsArticleNo>
<OrderQuantity>2</OrderQuantity>
<price>6,00</price>
</ListLineItem>
<ListLineItem>
<OrderPosNumber>2</OrderPosNumber>
<DistributorsArticleNo>100-005</DistributorsArticleNo>
<OrderQuantity>3</OrderQuantity>
<price>1,99</price>
</ListLineItem>
</ItemList>
</smd:order>
</post>
на файлы:
2021-12-29_12:50:31.xml
<?xml version="1.0" encoding="UTF-8"?>
<smd:order xmlns:smd="http://www.smd.com/xsd/COMMONTYPES/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" smd:DocumentType="ORDER">
<MessageHeader>
<DateOfMessage>2021-12-29 12:50:31</DateOfMessage>
</MessageHeader>
<OrderReference>322</OrderReference>
<OrderDate>2021-12-29 12:50:31</OrderDate>
<DeliveryDateRequested>2021-12-29 12:50:31</DeliveryDateRequested>
<Distributor>
<DistributorGLN>9001496000001</DistributorGLN>
</Distributor>
<OrderingParty>
<DistributorsOrderingPartyID>250002 </DistributorsOrderingPartyID>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Habr</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
<Email>67576575@yandex.ru</Email>
<Phone>+74845451564</Phone>
</OrderingParty>
<DeliveryRecipient>
<DeliveryRecipientGLN>9002804000119</DeliveryRecipientGLN>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Habr</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
</DeliveryRecipient>
<InvoiceRecipient>
<DeliveryRecipientGLN>34987349875793845</DeliveryRecipientGLN>
</InvoiceRecipient>
<ItemList>
<ListLineItem>
<OrderPosNumber>1</OrderPosNumber>
<DistributorsArticleNo>100-004</DistributorsArticleNo>
<OrderQuantity>1</OrderQuantity>
<price>6,00</price>
</ListLineItem>
</ItemList>
</smd:order>
2021-12-30_10:14:41.xml
<?xml version="1.0" encoding="UTF-8"?>
<smd:order xmlns:smd="http://www.smd.com/xsd/COMMONTYPES/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" smd:DocumentType="ORDER">
<MessageHeader>
<DateOfMessage>2021-12-30 10:14:41</DateOfMessage>
</MessageHeader>
<OrderReference>323</OrderReference>
<OrderDate>2021-12-30 10:14:41</OrderDate>
<DeliveryDateRequested>2021-12-30 10:14:41</DeliveryDateRequested>
<Distributor>
<DistributorGLN>9001496000001</DistributorGLN>
</Distributor>
<OrderingParty>
<DistributorsOrderingPartyID>250002 </DistributorsOrderingPartyID>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Moscv</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
<Email>xnjnjzbotq@yandex.ru</Email>
<Phone>+74845451564</Phone>
</OrderingParty>
<DeliveryRecipient>
<DeliveryRecipientGLN>9002804000119</DeliveryRecipientGLN>
<Address>
<LastName>Berd</LastName>
<FirstName>Ivan</FirstName>
<Street>Dorotheergasse 3</Street>
<Town>Moscv</Town>
<ZIP>1010</ZIP>
<CountryCode>ru</CountryCode>
</Address>
</DeliveryRecipient>
<InvoiceRecipient>
<DeliveryRecipientGLN>34987349875793845</DeliveryRecipientGLN>
</InvoiceRecipient>
<ItemList>
<ListLineItem>
<OrderPosNumber>1</OrderPosNumber>
<DistributorsArticleNo>100-007</DistributorsArticleNo>
<OrderQuantity>2</OrderQuantity>
<price>6,00</price>
</ListLineItem>
<ListLineItem>
<OrderPosNumber>2</OrderPosNumber>
<DistributorsArticleNo>100-005</DistributorsArticleNo>
<OrderQuantity>3</OrderQuantity>
<price>1,99</price>
</ListLineItem>
</ItemList>
</smd:order>
Все выходные файлы поместить в папку с названием исходного файла (в примере это Orders-Export-26)
Все заключается чтобы при каждом экспорте создавалась новая папка а в ней иметь по 1.xml на 1 заказ