Re: Re[2]: [xmljs-users] New to xml, looking for some guidance
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2004-07-07 15:10:57
|
<<Is a tag attribute a good way of categorizing groups of nodes, or should they all just be child nodes? From your example, I take it the latter?>> IMHO, it's better to organize them as child nodes. It make processing easier as well as making the XML code easier to humanly read. It's not always possible though - and the fact that XML still works in the non-perfect-world cases is one of the strong points of the technology. It would be very simple for you to modify the script to return all of the nodes with the specific attribute and value. In the getElementBy* function (either mine or yours) all you need to do is loop until you find a node you're interested in. Instead of returning the node and returning, add the node to a temp array or something and then return. Once you've looped through the entire tree, return the array. XML for <SCRIPT>'s license not only permits you to do this, but encourages you to do so! Best regards, David --- Christopher Brown <cb...@co...> wrote: > Hi David, > > DJ> The "id" tag is unique in XML. In ideal > DJ> worlds, all "id" tags would be unique in an > DJ> XML string. Thus, getElementById makes sense. > DJ> Since "id" is the only attribute with this > DJ> definition, a getElementByAttribute function > DJ> doesn't make sense for an XML parser. However, > DJ> if you need one, there is no reason why you > DJ> couldn't just modify XML for <SCRIPT> to > DJ> include it. All you would have to do is to > DJ> clone the code in getElementById. > > I see. I had never thought to modify the script. Would it be difficult to have it return all of > the nodes that match? I acknowledge your point about 'id' being ideally unique, but what about > another attribute, for which several nodes share a common value? I imagine that this would be a > quick way to organize data. I also imagine that this is what XPath is for? This is what I meant > by my question about a better way to organize my data. Now that I know a bit more of the > nomenclature, let me rephrase...Is a tag attribute a good way of categorizing groups of nodes, > or should they all just be child nodes? From your example, I take it the latter? > > >> Third, how can I use html links within my xml > > <snip>... > > DJ> This is the ugly part of trying to do XML with > DJ> javascript. > > <snip>... > > I see...Down & dirty. Sometimes there ain't no shortcuts. > > DJ> You're welcome. Good luck! > > Thank you for your thoughtful reply. > > -- > Chris > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |