So I've got an XML file (XML file) with a schema (XML schema).
I'm trying to create a quick Rails app to allow users to search through the XML file based on the 'lastName" element that are children of an sdnEntry element.
I don't have any problems setting up the rails app, or the search-form. I was also able to get the XML file loaded using Nokogiri and can run simple commands like...
xmldoc.css("lastName")
...to return a NodeSet with all the 'lastName' elements in them. Unfortunately, that's not good enough, since that lists not just the 'lastName' elements directly underneath an 'sdnEntry' element. Plus that doesn't even get me started to insert the user's input from the form. I was thinking something like this would work...
xmldoc.xpath("/xmlns:sdnList/sdnEntry/lastName[text()='#{param[:name]}']")
...but that didn't work. Oddly, I couldn't even get...
xmldoc.xpath("/xmlns:sdnList/sdnEntry/lastName")
...to work. I just don't know enough about Nokogiri or XPath or CSS queries for XML documents to figure out how to pass the param from user-input form to create the appropriate query that will return the right info for me.
I tried looking through the Nokogiri Documentation and the W3Schools XPath Tutorial. No joy.
I would really appreciate any pointers, code snippets or suggestions. Thank you.