sabre-io / xml

sabre/xml is an XML library that you may not hate.
http://sabre.io/xml/
BSD 3-Clause "New" or "Revised" License
516 stars 77 forks source link

Removing the namespace leaves {} prefix #289

Open tacman opened 2 months ago

tacman commented 2 months ago

I know I'm doing something wrong here, but I can't figure out what it is.

<recodList xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <script/>
    <count>5487</count>

    <record>
        <Title>Le Havre</Title>
//        https://sabre.io/xml/reading
        $this->service->elementMap = [
            'record' => function(Reader $reader) {
                return keyValue($reader, 'recodList');
            },
            'recodList' => function(Reader $reader) {
                return repeatingElements($reader, 'record');
            },
        ];

I know the namespaces can be removed by declaring them in the call, but there's no namespace, besides the default. I've tried using that, and using {}, but I can't seem to get rid of the brackets in the key names.

array:24 [▼
  "{}Title" => "Le Havre"
  "{}Description" => null

Thanks again for this library, I struggle with parsing XML, but this has made it much easier. It's really quite remarkable.