Joseph Michael Pesch
VP Programming

Transform URL List into HTML Unordered List

by 23. January 2012 16:16
This method will take a flat list of fully qualified URL's and transform them into nested bullets (i.e. HTML unordered lists).  It is a simple method to convert the flat list of URL's into a psuedo tree view.  Here is the C# code to transform the list.
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Xsl;

namespace UrlListToSiteMap
{
  public class Program
  {
    public static void Main(string[] args)
    {
      /*
         This method accepts a text file of fully qualified URLs 
         and will convert into HTML unordered list. 
      */
      string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
      List urlRecords = File.ReadAllLines(path + @"\UrlList.txt").ToList();
      urlRecords.Sort();
      XmlDocument doc = new XmlDocument();
      doc.AppendChild(doc.CreateNode(XmlNodeType.Element, "SiteMap", ""));
      XmlNode rootNod = doc.ChildNodes[0];
      foreach (string url in urlRecords)
      {
        XmlNode pathNod = rootNod;
        int iNod = 0;
        int iNods = url.ToLower()
          .Replace(@"http://", "").Replace("'", "").Split('/').Count();
        foreach (string nod in url.ToLower()
          .Replace(@"http://", "").Replace("'", "").Split('/'))
        {
          iNod++;
          System.Diagnostics.Debug.WriteLine(nod);
          XmlNode subNod = pathNod.SelectSingleNode("Node[@URL='" + nod + "']");
          if (subNod == null)
          {
            System.Diagnostics.Debug.WriteLine(pathNod.Name);
            string nodType = iNod.Equals(iNods) ? "Leaf" : "Node";
            subNod = doc.CreateNode(XmlNodeType.Element, nodType, "");
            XmlAttribute atr = doc.CreateAttribute("URL");
            atr.Value = nod;
            subNod.Attributes.Append(atr);
            pathNod.AppendChild(subNod);
          }
          pathNod = subNod;
        }
      }
      doc.Save(path + @"\SiteMap.xml");
      XslTransform xslt;
      xslt = new XslTransform();
      xslt.Load(path + "SiteMap.xslt");
      xslt.Transform(path + "SiteMapNew.xml", path + "SiteMap.html");
    }
  }
}

Attached is the XSLT file for the transformation. NOTE: If you only want the folders and not the actual documents, remove the "Leaf" section from the XSLT.

SiteMap.xslt (583.00 bytes)

Tags:

C# | HTML

JavaScript Drop Down Menu Example

by 18. May 2011 08:31

Tags:

CSS | HTML | JavaScript

Default and Disable Zoom in Handheld Device Browsers

by 29. January 2011 20:34

<meta content='True' name='HandheldFriendly' />

<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />

<meta name="viewport" content="width=device-width" />

Tags:

HTML

HTML JavaScript Web Service Call

by 17. September 2010 14:56

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

  <title></title>

  <script type="text/javascript">

    function MakeSoapCall(WebServiceUrl, Namespace, WebMethod, WebMethodParams) {

      var xmlHttp;

      function SoapCall() {

        // creatng the xmlHttp object

        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

        // Calling the web service using post and true means asynchronous call

        // WebServiceUrl Sample: http://localhost/MyWebService.asmx

        xmlHttp.open("post", WebServiceUrl, true);

        // Setting the request header to let the web service identify the soap request we would be sending

        xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

        // SoapAction Sample: http://MyNameSpace.com/MyWebMethod – name of the webmethod

        // Example: [WebService(Namespace = "http://MyNameSpace.com/")] applied to our web service class

        xmlHttp.setRequestHeader("SOAPAction", "http://" + Namespace + "/" + WebMethod);

        xmlHttp.onreadystatechange = doUpdate;

        // setting the soap request body

        var soapRequest = "<?xml version='1.0' encoding='utf-8'?>" +

          "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +

          " xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +

          "<soap:Body>" +

          "<" + WebMethod + " xmlns='http://" + Namespace + "/'>" +

          WebMethodParams +

          "</" + WebMethod + ">" +

          " </soap:Body>" +

          "</soap:Envelope>";

        // send the request

        document.all('WebMethodParamsTextArea').value = soapRequest;

        xmlHttp.send(soapRequest);

        return false;

      }

      function doUpdate() {

        debugger;

        if (xmlHttp.readyState == 4) {

          var responseXMLResult = xmlHttp.responseXML;

          // var result = responseXMLResult.lastChild.nodeTypedValue;

          alert(responseXMLResult.xml);

        }

      }

      SoapCall();

    }

   

  </script>

</head>

<body>

  <form id="form1" runat="server">

  <div style="font-family: Calibri;">

    <table>

      <tr>

        <td>

          Web Service URL:

        </td>

        <td>

          <input type="text" id="WebServiceUrlControl" size="100" value="http://www.27seconds.com/Holidays/US/Dates/USHolidayDates.asmx" />

        </td>

      </tr>

      <tr>

        <td>

          Namespace:

        </td>

        <td>

          <input type="text" id="NamespaceControl" size="100" value="www.27seconds.com/Holidays/US/Dates" />

        </td>

      </tr>

      <tr>

        <td>

          Web Method:

        </td>

        <td>

          <input type="text" id="WebMethodControl" size="100" value="GetChristmasDay" />

        </td>

      </tr>

      <tr>

        <td valign="top">

          Web Method Paramaters:

        </td>

        <td>

          <textarea id="WebMethodParamsTextArea" rows="5" cols="75">

<year>2010</year>

          </textarea>

        </td>

      </tr>

      <tr>

        <td>

        </td>

        <td>

        </td>

      </tr>

    </table>

    <br />

    <input type="button" value="Make Soap Call" onclick="MakeSoapCall(document.all('WebServiceUrlControl').value, document.all('NamespaceControl').value, document.all('WebMethodControl').value, document.all('WebMethodParamsTextArea').value);" />

  </div>

  </form>

</body>

</html>

 

 

Tags:

HTML | JavaScript

HTML Opacity

by 16. February 2009 18:21

<scriptid="SetOpacity"type="text/javascript"language="Javascript">
function SetOpacity(obj, val) { val = (val > 100) ? 100 : val;
val = (val < 0) ? 0 : val;
obj.setAttribute('SetOpacity', val); alert(obj.id);
if (navigator.appName.indexOf("Netscape") != -1 && parseInt(navigator.appVersion) >= 5) { obj.style.MozOpacity = val / 100;
obj.style.opacity = val / 100;
}
elseif (navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion) >= 4) { obj.style.filter = 'alpha(opacity=' + val + ')'; //obj.filters.alpha.opacity = val





}
}
</script>

Tags: ,

HTML

HTML Div Win (divwin) Floating Windows

by 22. December 2008 15:59

HTML Div Win (divwin) Floating Windows with Auto Alignment and Expand/Collapse feature.  This is an HTML layout with javascript that allows auto alignment, collapsable, draggable/movable, inline virtual windows (divs with content and/or iFrames).  Here is the sample html code: divwin.zipx (258.48 kb)

See sample screen shot below.

Tags:

HTML

Error Using Interop.SourceTypeLib.dll on Machine without VSS Installation

by 20. October 2008 14:27

Error: Retrieving the COM class factory for component with CLSID {783CD4E4- 9D54-11CF-B8EE-00608CC9A71F} failed due to the following error: 80040154.

Received when installing a .MSI (built in VS2008) onto a server that doesn't contain VSS application installation.  The VS2008 project was referencing Interop.SourceSafeTypeLib.dll (which was being copied into the insallation directory).  To resolve this issue I needed to also copy SSAPI.dll (from the local development machine VSS program directory) into the deployment folder on the target machine and register it (e.g. regsvr32 .../ssapi.dll where .../ is the actual path of the dll file).  Additionally, you will need a sub-folder (in the folder containing the ssapi.dll) and a copy of the ssui.dll in that folder (see diagram below).  The attached zip file contains the 3 dll's referenced below.

 

C:\Program Files\Microsoft Visual SourceSafe\ssapi.dll  [Target]\ssapi.dll (run regsvr32 on this one) 
C:\Program Files\Microsoft Visual SourceSafe\1033\ssui.dll [Target]\1033\ssui.dll (must be in 1033 sub-folder)
<Don't know where it originates from> [Target]\Interop.SourceSafeTypeLib.dll 

VSS.zip (488.50 kb)

Tags:

HTML | VSS

HTML Format Issue - Gaps around images in table cells

by 7. October 2008 15:04

Having a line feed in the HTML source can cause an gap (what would appear to be a padding issue).

BAD
<table>
  <tr>
    <td> <!-- the line feed here can cause spacing issues -->
      <img src="..." style="width: 100px; height: 100px" />
    </td> <!-- the line feed here can cause spacing issues -->
  </tr>
</table>

GOOD
<table>
  <tr>
    <td><img src="..." style="width: 100px; height: 100px" /></td>
  </tr>
</table>

Tags:

HTML