Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Eloquence Denied?: getElementsByTagName Date: Wed, 28 May 2014 09:50:11 -0400 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 28 May 2014 13:50:14 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="19839"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18La9PuLngPC35OrcsZJMyd" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Cancel-Lock: sha1:QM1ACdABpsZN0TfbPR2k+kwWggY= Xref: csiph.com comp.lang.java.programmer:28576 On 5/28/2014 9:04 AM, clusardi2k@aol.com wrote: > Is there an alternative way to write the below program without hardcoding "person", "first", "last", and "age" or putting these into a file and reading the contents of a file. > [... code snipped; see up-thread ...] I can't think of any. You can certainly navigate the DOM without foreknowledge of the tag names, but that won't tell you what to do with each tag. That is, there's nothing in the XML itself to tell you to count the number of `person' tags, nor to print "Last Name : " before the content of each `last' tag. For that matter, there's nothing in the XML that tells your program to ignore the `citizenship' tags. To put it another way: The XML data doesn't know which parts of itself your program might be interested in, nor what your program should do with them. It's up to your program to know these things. -- Eric Sosman esosman@comcast-dot-net.invalid