Jump to content

xtiancjs

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by xtiancjs

  1. A brief overview of how I would start this. Seems like there will be multiple calls to a base url with some changing parameters. looking here: http://www.loc.gov/standards/sru/simple.html points 2, 3, and 5 seem like the way to start. So essentially you are making an initial call to give you the number of records, then the same call a bunch of times to get the next set based upon your parameters in the url. I would create a class file that deals with all this in an oop fashion. You would have a method that sends the requests, I would use curl, and a method that deals with parsing the xml - simpleXml(for the simple xml look into parsing children of namespaces in this case "zs" - simple xml can definitely parse these results just have to experiment with the correct syntax and combo of children() etc.). No need to actually write data to a file or DB until you really need to at the end for a single record.
  2. also, if you are just getting the xml from a remote address and you wish to just write the raw contents to a file, you don't need simple xml till later. Simple xml is for parsing and writing xml. You could also get the page contents using curl.
  3. Also, I highly discourage doing a string replace on the ":" in your returned xml. The ":" denotes the namespaces in the xml string. You will run into troubles trying to parse your file later on.
  4. Just worked on something similar, try this : $url = file_get_contents('http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5'); $xml = new SimpleXMLElement($url) ; //file put contents - same as fopen, wrote and close //need to output "asXML" - simple xml returns an object based upon the raw xml file_put_contents(dirname(__FILE__)."/loc.xml", $xml->asXML());
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.