Hacker News new | past | comments | ask | show | jobs | submit login

If you can parse

    <results>
      <result></result>
    </results>
and you end up with a single "result" object, you must have identified "results" as being an array of one element so that you could discard it. (You didn't get a single "results" object.)

That's not a problem in what XML is able to model, it's a problem with you throwing the information you got away and then pretending you didn't receive it.

On the other hand, if you meant that you get a single "results" object, then you're saying that your code is written to require invalid XML and fall down when valid XML is provided. Again, that sounds more like a problem with your code than with the modeling capabilities of XML. There's an argument to be made for accepting invalid input; rejecting valid input is ridiculous.




You do understand that php and quite a few other languages provide pre-built serialization and de-serialization from XML, right? The OP was talking about the out of box behaviour for those. Your answer seems to predicate on having written a custom deserializer.


My answer is predicated on the idea that you should be using a deserializer that doesn't rely on receiving invalid input, regardless of whether that deserializer comes from a standard library.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: