archigar 0 Posted February 23, 2012 Report Share Posted February 23, 2012 I am a beginner and a building architect and not a developer, so please take pity. Ok, I have a XML file eported from an application, the data contains everything from materials to 3D info. I would like to extract a list of room numbers to a MySQL db and be able to pull that information into a dropdown selectable list for use by users on a web form. I have been using the loadxmldoc.js script from the tutorial to parse the file as a first step. The question is where do I go next? Also, the parsed text has a tag of "Name" and is a child of "Space". However, just parsing 'Name' brings with it the child text from Parents - "Location" and "Coordinate" which are different levels of the XML documents but have the same "Name" tags. How can I only pull the Space/Name text? and how can I get this to populate a drop down menu? Thank you in advance. Quote Link to post Share on other sites
boen_robot 107 Posted February 24, 2012 Report Share Posted February 24, 2012 You can do it with XPath, but XPath with JavaScript is tricky. Plus, you want to put that information into a MySQL database, so JavaScript is not appropriate anyway.PHP has a DOM API which is close to what you have in JavaScript. For loading the file, there's DOMDodument::load() (check out the example), and the rest is mostly a matter of replacing JavaScript's "." with PHP's "->".To use XPath, you need to load a document, and then use DOMXPath::query() (as demonstrated in the examples).The XPath query you need is "//Space/Name". Check out The XPath tutorial for details on XPath's syntax. Quote Link to post Share on other sites
archigar 0 Posted February 24, 2012 Author Report Share Posted February 24, 2012 boen_robot, I will give it a run, see if I can get it to work, and report back. Seems pretty straight forward. Thanks for the response. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.