0

Disclaimer: This is a conceptual question and so I'm posting here rather than stackoverflow or wordpress.stackexchange

Okay, so I need to import XML data into WordPress and parse it to populate a form created with the Gravity Forms plugin. A few notes:

  1. WP prohibits the uploading of XML files
  2. Only trusted users will have access to the page on which this functionality will live
  3. Data entry plugins are fair game to be apart of the process.
  4. I'm building this on the Divi theme
  5. The XML file in question will be ~4k lines
  6. This will rarely (if ever) be used from a mobile device

My current approach is this:

  1. Use a divi code block and some jQuery to harness the necessary input fields on a page. Like, a file picker, a drop-down or two to give the site some idea of which form it needs to format the data into (right now, it's just one, but more will come), and a button.
  2. The user would then pick the file, and click the button to kick off the function. I'm thinking of doing most of the XML file processing client-side since javascript gives me access to xPath, and xmltojson. This would then be sent to the server via an AJAX call.
  3. The server would then handle the call, populate the form, and then notify the user on success/failure.

Other ideas

Create a plugin that creates a shortcode to inject the necessary file-upload field, type selectors, and button onto a page

Save the XML file as a .txt file and upload it anyway -> just have the php processing it on the other side expect it and handle it as xml (is php xml processing better or worse than javascript? Same? #stuffIneedtoResearch)

Create a stand-alone application in some other language (I'd probably pick java) to convert the xml to a flat file (this would be my answer if I discovered client-side xml processing was a bad idea).

Question: Is this approach okay? Terrible? Please let me know what would be better. Remember, I'm not asking for code here. I simply feel like there's a few client-server concepts and best practices that I'm missing and would appreciate if someone would point me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.