0

I have a list of buildings I want people to be able to search for, and inside those buildings are an undetermined number of offices, perhaps none. My project is XML based and I'm pulling the buildings into an array as my source for jQuery autocomplete.

I have no problem getting a simple building search to work, the wrinkle is searching for offices as the goal is for only buildings to be returned. If you search for Office1, and Office1 is within Building1, then Building1 should be returned. Both Office1 and Building1 should show up in autocomplete.

I've tried two dimensional arrays like

var items = [[building,office,office],[building],[building, office]];

And I've also explored objects (use a array of objects as source for jQuery UI AutoComplete), thinking multiple offices could be associated with one building "label" within autocomplete but nothing quite seems to work in implementation.

1 Answer 1

1

Use JSON. It's a native JavaScript object so you don't need to parse it, making it 100 times faster than XML.

There are a lot of libraries to convert XML to JSON on the server.

Sign up to request clarification or add additional context in comments.

1 Comment

Project requirements stipulate XML and JSON wouldn't make this any easier, it'd just cut some fat. Given the number of buildings/offices I have (small) things are plenty fast enough. It's really outside the scope of my problem but I've setup an index XML file that's used for autocomplete and separate XML files for each building to keep loads snappy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.