[thelist] Creating objects with JS, XML, and the DOM DOM DOM...

Matt Warden mwarden at gmail.com
Fri Aug 10 10:52:31 CDT 2007

On 8/10/07, Ben Joyce <ben.joyce at gmail.com> wrote:
> Then, I can use User.FirstName to access my data rather than repeating
> the whole "getElementsByTagName" thing each time.  However, this seems
> a bit long-winded... I'm guessing there might be an easier way to read
> the value of the FIRST_NAME from the XML object rather the User object
> - just not sure how!
> Do I even need to bother with a User object?  Would I be better off
> just storing the XML object and getting data direct from there?

It is hard to say for sure not knowing what you're using this for, but
I would say that 9 times out of 10 it is better to treat the XML as a
serialized version of an object, unserialize it into an object like
you are doing, and then never worry about the XML again in your code.
In most cases this makes it many times easier to reuse your code. It
also will make the code more readable.

Matt Warden
Cincinnati, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list