Jump to content

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


archigar

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...