Finding relationship between xml nodes using js and or php

wesley18

New Member
this is more of a speculative question as to what you all consider to be the best approach or smartest method to a particular problem I have.I am developing a web app currently which is largely driven by a huge XML tree. The point of the app is to randomly generate an appropriate sequence of nodes based on their relationship to one another.The nodes are really well categorized but the initial selection needs to be largely stochastic and the next selections based on the first node. The choices should be random but there should not be a noticeable and logical similarity between each selection.For example given the following tree:\[code\]<things> <foods> <fruits> <fruit>apple</fruit> <fruit>orange</fruit> <fruit>melon</fruit> <fruit>banana</fruit> <fruit>grape</fruit> </fruits> <vegetables> <vegetable>potato</vegetable> <vegetable>carrot</vegetable> <vegetable>onion</vegetable> <vegetable>leek</vegetable> </vegetables> </foods> <animals> <birds> <bird>penguin</bird> <bird>ostrich</bird> <bird>parrot</bird> <bird>crow</bird> <bird>emu</bird> </birds> <fish> <fish>cod</fish> <fish>plaice</fish> <fish>salmon</fish> <fish>shark</fish> <fish>tuna</fish> </fish> </animals></things>\[/code\]... if the first item selected is shark, then tuna is a close relative, though an item from the birds category is also accessible as it holds a certain similarity - it is a living thing. However, a vegetable is entirely unrelated and should not be selected.Considering the fact that my xml tree is absolutely huge I need an intelligent way of performing similarity checks.Any thoughts, opinions, or guidance is greatly appreciated. I have searched for a solution on this already but so far have come up with very little.Thanks in advance!
 
Back
Top