Jump to content

Newbie Realworld Question - Utilizing Exported XML file in MySQL/User input


archigar
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...