Every ms counts

JSON-Bible-Object

I’m trying to teach myself this workflow and how to get all of the code to interact.

The red connection and path are what I just stopped on.  The JSON is working like a charm.  In creating the PHP Web Service, I ran into a bit of an obstacle with large sections of scripture verses.  The XPath query on the Full XML File was getting taxed pretty hard when iterating through the bible’s data structure with a do-while loop.  Returning over 300 verses and here’s what the do-while loop looked like:

Do-While Loop

The do-while loop was iterating through the xml nodes linearly (since the bounds are known by the bible verse locations).  It had to do a switch statement on the node type to determine how to output the JSON.  Needless to say, it was a lot of operations for every node.

Instead, I changed it to target the XPath so it iterates with the exact path, already knowing every node type.  The difference was dramatic:

For Loop

My next step is to finish connecting the PHP code to the database (green line).  Then, once I know it works, I’ll put it into a WordPress plugin.  Hopefully it will be live on DiscipleShare before 2011!

Speak Your Mind