readNytFeedsXml script

on readNytFeedsXml () {
  Changes
    5/9/22; 11:29:52 AM by DW
      «Created.
  local (f = "Macintosh HD:Users:davewiner:Tmp:nytfeeds.xml")
  local (fdest = "Macintosh HD:Users:davewiner:publicfolder:misc:nytFeedsOpmlList:tmp.opml");
  local (xmltext = file.readwholefile (f))
  xml.compile (xmltext, @scratchpad.nytstruct)
  local (xstruct = @scratchpad.nytstruct);;
  local (adroutline = @scratchpad.nytSublist);
  new (outlinetype, adroutline);
  target.set (adroutline);
  edit (adroutline);
  window.setTitle (adroutline, "NYT Feeds");
  for (adrul in xstruct) {
    for (adrli in adrul) {
      for (adra in adrli) {
        msg (xml.getattribute (adra, "href")^);
        op.insert (xml.getvalue (adrli, "a"), down);
        op.attributes.setone ("type", "rss");
        op.attributes.setone ("xmlUrl", xml.getattribute (adra, "href")^)}}};
  op.firstsummit ();
  op.deleteline ();
  local (opmltext = op.outlinetoxml (adroutline));
  file.writewholefile (fdest, opmltext)};
bundle { //test code
  readNytFeedsXml ()}