Search

What is XML?


  • XML stands for EXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to carry data, not to display data
  • XML tags are not predefined. You must define your own tags
  • XML is designed to be self-descriptive
  • XML is a W3C Recommendation


The Difference Between XML and HTML

  • XML is not a replacement for HTML.
  • XML and HTML were designed with different goals:
  • XML was designed to transport and store data, with focus on what data is
  • HTML was designed to display data, with focus on how data looks
  • HTML is about displaying information, while XML is about carrying information.
  • XML Does Not DO Anything


Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store, and transport information.

The following example is a note to Tove, from Jani, stored as XML:

 <note>
 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
 </note>


The note above is quite self descriptive. It has sender and receiver information, it also has a heading and a message body.

But still, this XML document does not DO anything. It is just information wrapped in tags. Someone must write a piece of software to send, receive or display it.

  • With XML You Invent Your Own Tags


The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document.

That is because the XML language has no predefined tags.

The tags used in HTML are predefined. HTML documents can only use tags defined in the HTML standard (like <p>, <h1>, etc.).


  • XML allows the author to define his/her own tags and his/her own document structure.
  • XML is Not a Replacement for HTML
  • XML is a complement to HTML.


It is important to understand that XML is not a replacement for HTML. In most web applications, XML is used to transport data, while HTML is used to format and display the data.

My best description of XML is this:

  • XML is a software- and hardware-independent tool for carrying information.
  • XML is a W3C Recommendation
  • XML became a W3C Recommendation on February 10, 1998.
  • XML is Everywhere
  • XML is now as important for the Web as HTML was to the foundation of the Web.
  • XML is the most common tool for data transmissions between all sorts of applications.



There are 5 predefined entity references in XML:

  1. &lt; < less than
  2. &gt; > greater than
  3. &amp; & ampersand
  4. &apos; ' apostrophe
  5. &quot; " quotation mark




Valid XML Documents

A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD):

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "Note.dtd">
 <note>
 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
 </note>


The DOCTYPE declaration in the example above, is a reference to an external DTD file. The content of the file is shown in the paragraph below.
XML DTD

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

<!DOCTYPE note [
 <!ELEMENT note (to,from,heading,body)>
 <!ELEMENT to (#PCDATA)>
 <!ELEMENT from (#PCDATA)>
 <!ELEMENT heading (#PCDATA)>
 <!ELEMENT body (#PCDATA)>
 ]>


If you want to study DTD, you will find our DTD tutorial on our homepage.
XML Schema

W3C supports an XML-based alternative to DTD, called XML Schema:

<xs:element name="note">
 <xs:complexType>
   <xs:sequence>
     <xs:element name="to" type="xs:string"/>
     <xs:element name="from" type="xs:string"/>
     <xs:element name="heading" type="xs:string"/>
     <xs:element name="body" type="xs:string"/>
   </xs:sequence>
 </xs:complexType>


 </xs:element>

Attributes in C#


In the C# programming language, attributes are metadata attached to a field or a block of code, equivalent to annotations in Java. Attributes are accessible to both the compiler and programmatically through reflection.

Users of the language see many examples where attributes are used to address cross-cutting concerns and other mechanistic or platform uses. This creates the false impression that this is their sole intended purpose.

Their specific use as meta-data is left to the developer and can cover a wide range of types of information about any given application, classes and members that is not instance specific. The decision to expose any given attribute as a property is also left to the developer as is the decision to use them as part of a larger application framework.

Attributes should be contrasted against XML Documentation which also defines meta-data but is not included in the compiled assembly and therefore cannot be accessed programmatically.

Core Differences Between ASPNET Development Server and IIS




1. Security Context - In ASPNET Development Server, it is determined by who you login as on your computer. In IIS, it is typically IUSR_MachineName.

2. Accessing Static Pages - In ASPNET Development Server, you can not access static pages in a secure folder if you are not logged in, but in IIS, you can.

WriteLog() - The Easy Way to Display Debugging Information in ASP.NET

It can often be difficult to display information in ASP.NET because System.Diagnostics, Response.Write, or the Trace object are not available - for example, when you are working in the global.asax or inside a class.

A simple way to display what lines are executing and what information is in a given field is by creating a simple  WriteLog() method in a class in the App_Code folder. Then, when you want to display the contents of a field anywhere in your program, you just use:

C#:
clsWriteLog.WriteLog("strXyz: " + strXyz);

VB.NET:
clsWriteLog.WriteLog("Line 203 executed")

You have two ways to view what is written to the log:

1. While in Visual Studio, you look at trace.log file in your root directory.

2. While in the website, you type http://www.yourwebsitename.com/trace.log

You can download the few lines of code for the class  clsWriteLog at clsWriteLog .  The code for the class is provided in vb.net and c#.

How Http.Request and Http.Response Work in ASP.NET


Prerequisites (Getting Your Website Publicly Hosted): 


Step 1: Buy Domain name from a Domain Registrar like GoDaddy (costs about $8.00 for 1 yr). This connects the domain name that you purchase to a unique ip address - example http://myqol.com is connected to 96.31.43.8 

Step 2: Buy asp.net hosting package from hosting company like DiscountAsp (costs about $10 each month) - the hosting company needs to use Microsoft's IIS (Internet Information Server) on a Windows operating system - it cannot use Apache Server on a Linux operating system 

Step 3: Buy add-on for SQL Server database from DiscountAsp (costs $10 a month) - this step can be skipped if you have already bought an add-on database for another web site, and you only want to add some tables to that existing database. 

Step 4: Update nameservers in GoDaddy to point to DiscountAsp nameservers. DiscountAsp sends you in an email telling you the nameservers to use: for example, ns1.discountasp.net, ns2.discountasp.net, ns3.discountasp.net 

Step 5: Publish, Web Copy, or FTP your website from the folder it was in when you developed it in Visual Studio to the ftp folder on DiscountAsp. For example, ftp.myqol.com 



Intial Http.Request: 

1. You enter the domain name into your browser (this is known as the client machine) - ex. http://myqol.com 

2. Domain Name Server on internet translates the domain name (http://myqol.com) into the ip address (96.31.43.8) that you bought from GoDaddy. GoDaddy takes ip address (96.31.43.8) and passes the request to Name Servers on DiscountAsp: ns1.discountasp.net, ns2.discountasp.net, ns3.discountasp.net 

3. DiscountAsp NameServers do port forwarding to translate the ip address you bought from GoDaddy (96.31.43.8) to a unique local ip address on DiscountAsp (192.168.5.94) 

4. Local address (192.168.5.94) on DiscountAsp points to your website hosted in IIS and that connects you to the folder where you Published, Web Copy-ed, or FTP-ed your website 

5. The Http.Request for a page reaches IIS on the DiscountAsp server (this is known as the server machine - hence, that is why the architecture is referred to as being client-server). The TCP/IP connection on the server was in the "listening" state, but now the connection state is changed to being "established." IIS checks to see if you have the authority to access the page. 



Initial Http.Response: 

If you do have the authority, the web server executes the code behind instructions to construct a web page and sends it to the ip address of the computer that requested the page 

Three Possible Scenarios after Initial Http.Request: 

Scenario #1 Request: you hover your mouse over a field 

Scenario #1 Response: javascript on the page that was sent to your browser executes without returning to the server and displays a tool tip on the page very efficently. 

Scenario #2 Request: you click on a button that is contained within in a ajax panel. 

Scenario #2 Response: javascript on the page only sends the information in the ajax update panel to the server and the server does whatever your code behind tells it. This allows the server to return a response without doing a full postback and without returning everything on the page - this is more efficient than doing a full postback 

Scenario #3 Request: you click on a submit button for a form that is not contained in ajax panel. This sends all the info on the page to the server in Http.Request 

Scenario #3 Response: Full PostBack Occurs: 

1. The server executes your code-behind instructions to do whatever is needed. For example, the code-behind instructions may cause the server to execute instructions to send commands to SQL Server that will insert the information in the form into the database. Once all the commands in the code-behind are executed the server sends back a Http.Respone with any information updated that the code behind said to update - for example, labels on the web form may be modified to indicate the update was successful 

2. The Http.Request and Http.Response are now complete and the transaction is over until you initiate another one with the mouse or keyboard. 

3. When you navigate away from the website, the TCP/IP connection changes from being in the "established" state to being "closed."

.NET Framework


What is it?

It is a virtual machine that includes a large class library.

Why use it?

Reuse code for basic functions
Security
Memory Management
Safe sandboxes for applications.