NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.53k stars 303 forks source link

isArray behavior on missing/empty tags #619

Open faljse opened 11 months ago

faljse commented 11 months ago

"isArray" is true for References.Reference "alwaysCreateTextNode" is true

case 1:

  <UAReferenceType>
    <References>
      <Reference></Reference>
    </References>
  </UAReferenceType>

UAReferenceType.['References'] is an array

case 2:

  <UAReferenceType>
  </UAReferenceType>

UAReferenceType.['References'] is now undefined; evals to false

case 3:

  <UAReferenceType>
     <References />
  </UAReferenceType>

UAReferenceType.['References'] now contains an object with ['#text']; evals to true

isarray saves me from a lot of extra checks; still it seems like this could be improved?

github-actions[bot] commented 11 months ago

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.