Jump to content

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


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...