Php regular repeated interception of strings

the data I get is like this
this is xml data

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
        <p237:getNewSampleSerialNumsOutput xmlns:p237="http://www.cat.com/sos/2008/07/15/EquipmentService/">
            <Equipment>
                <p463:serialNumber xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15">ZBD11674</p463:serialNumber>
                <p463:make xsi:nil="true" xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15"/>
            </Equipment>
            <Equipment>
                <p463:serialNumber xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15">ZBF11179</p463:serialNumber>
                <p463:make xsi:nil="true" xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15"/>
            </Equipment>
            <Equipment>
                <p463:serialNumber xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15">ZBF11507</p463:serialNumber>
                <p463:make xsi:nil="true" xmlns:p463="http://www.cat.com/dds/Equipment/2008/07/15"/>
            </Equipment>
        </p237:getNewSampleSerialNumsOutput>
    </soapenv:Body>
</soapenv:Envelope>

then I want to intercept them into an array according to the tag Equipment (the content is obtained together with the tag) [I really can"t do it without the tag, I"ll add it myself]

then the code goes like this

preg_match_all("/<Equipment>.*<\/Equipment>/",$res,$a);

but what you get is to intercept the first < Equipment > to the last < / Equipment >, and the middle area does not recognize

.

clipboard.png

is there any optimization method

Mar.24,2022

str.match(/[^><]+(?=<\/Equipment>)/img;

php doesn't know much about this. This is what's in the js regular match tag

.

your way of writing is correct. The tag and the content are taken out together. If you want to take the content between the tags, use / < Equipment > (. *) <\ / Equipment > /' to

.

you should release the whole html and see what the problem is


<Equipment>[\s\S]+?<\/Equipment>

Click to view

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44461-437d8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44461-437d8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?