1 XML Parsing in C# Why.NET is worth it…. 2 Introduction C# was designed around the.NET platform for… Similarity to C++ Similarity to C++ Safety and ease.

Slides:



Advertisements
Similar presentations
XML & Data Structures for the Internet Yingcai Xiao.
Advertisements

Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
Introduction to the C# Programming Language for the VB Programmer.
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
ASP.NET Programming with C# and SQL Server First Edition
Intro to C# Language Richard Della Tezra IS 373. What Is C#? C# is type-safe object-oriented language Enables developers to build a variety of secure.
 2007 Pearson Education, Inc. All rights reserved C++ as a Better C; Introducing Object Technology.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
.NET and XML (or XML in.NET) David Oguns Matt Harding.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
XML.NET Concepts and Implementation Badar Gillani.
An Introduction to C# and the .NET Framework
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
C# Tutorial From C++ to C#. Some useful links Msdn C# us/library/kx37x362.aspxhttp://msdn.microsoft.com/en- us/library/kx37x362.aspx.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Programming Languages and Paradigms Object-Oriented Programming.
Introduction to .Net Framework
Module 1: Introduction to C# Module 2: Variables and Data Types
Session 1 - Introduction and Data Access Layer
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
.NET Framework & C#.
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
CSC 494/594 C# and ASP.NET Programming. C# 2012 C# Object-oriented language with syntax that is similar to Java.
Neal Stublen Class Objectives  Develop an understanding of the.NET Framework  Gain proficiency using Visual Studio  Begin learning.
Presentation XML. NET SEMINAR By: Siddhant Ahuja (SID)
Assemblies & Namespaces1. 2 Assemblies (1).NET applications are represented by an assembly An assembly is a collection of all software of which the application.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
FEN 2012 UCN Technology: Computer Science1 C# - Introduction Language Fundamentals in Brief.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Component-Based Software Engineering Introduction to.NET Paul Krause.
.NET Framework Danish Sami UG Lead.NetFoundry
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
Лектор: Борислава Палева. Galin Iliev MCT, MCPD, MCSD.NET LINQ to XML.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Module 3: Working with Components. Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating.
Introduction to Exception Handling and Defensive Programming.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
1 C# A brief overview by Jack Senechal and Bryan Powell.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
CSD 340 (Blum)1 Making and Reading from XML Files Chapter 14 of Beginning JavaScript (Paul Wilton)
.NET and XML (or XML in.NET) Matt Harding David Oguns.
Managing C++ CHRIS DAHLBERG MID-TIER DEVELOPER SCOTTRADE.
Introduction to Object-Oriented Programming Lesson 2.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Wel come To Seminar On C#.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Module 1 Introducing C# and the.NET Framework. Module Overview Introduction to the.NET Framework 4 Creating Projects Within Visual Studio 2010 Writing.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Object-Oriented Programming (OOP) and C++
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
D OTNET ONLINE TRAINING. DOTNET Online Training Course Content : Introduction to.Net Online Training NET FUNDAMENTALS Why Dot Net? The Dot Net initiative.
C# and the .NET Framework
Introduction to C# AKEEL AHMED.
Processing XML.
Chapter 2: Java Fundamentals
IS 135 Business Programming
Presentation transcript:

1 XML Parsing in C# Why.NET is worth it…

2 Introduction C# was designed around the.NET platform for… Similarity to C++ Similarity to C++ Safety and ease of use Safety and ease of use True OOP structure True OOP structure Interoperability with other languages (instantiate a C++ class in C#) Interoperability with other languages (instantiate a C++ class in C#) Allowing existing code to be used (ie – COM objects, DLLs) Allowing existing code to be used (ie – COM objects, DLLs)

3 Introduction What languages influenced its creation? Visual Basic (Rapid App Dev capabilities) Visual Basic (Rapid App Dev capabilities) Java (Type-safe Ref Modeling) Java (Type-safe Ref Modeling) C++ (Power inherited from C) C++ (Power inherited from C) Smalltalk (true object-oriented structure) Smalltalk (true object-oriented structure) … along with a number of predecessors

4 The.NET Framework Base Class Library containing hundreds of classes Base Class Library containing hundreds of classes Contains underlying object-oriented principles as well as assembly technology Contains underlying object-oriented principles as well as assembly technology All classes are based on one specific class in the BCL All classes are based on one specific class in the BCL

5 Basic C# Namespaces used instead of include or import calls Namespaces used instead of include or import calls using System; using System.IO; using System.Xml; This acts as a container for underlying classes, such as Console, XML parsing functions This acts as a container for underlying classes, such as Console, XML parsing functions Console.WriteLine(“It is called Mario Twins”); XmlDocument xmlDoc = new XmlDocument();

6 C# Code Structure using System;// Include the namespace public class SampleCode {// Create your first class public static void Main() {// Main declared within the class int x, y; Console.Write(“Enter two numbers: “);// Write text x = Convert.ToInt32(Console.ReadLine()); // Convert input to int y = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(“The sum is “ + Sum(x,y)); // Write text & vars } public static int Sum(int a, int b) { return(a + b); } }// End of class

7 C# OOP Structure OOP structure almost identical to C++ in terms of classes, structs OOP structure almost identical to C++ in terms of classes, structs Just like C++, it contains private and public member variables and functions Just like C++, it contains private and public member variables and functions The Main() is placed in one of the classes, and the compiler enters runtime via this function The Main() is placed in one of the classes, and the compiler enters runtime via this function Namespaces can be used to contain classes for organization Namespaces can be used to contain classes for organization

8 XML Parsing Features Using the System.Xml namespace, Using the System.Xml namespace, XmlDocument xmlDoc; // Our XML doc to be loaded XmlTextWriter writer;// The stream we’ll used to … write out the results // Load the doc … writeFileName = myCourse.getCrsNum() + “.xml”; writer = new XmlTextWriter(writeFileName, null); // Open the … output file writer.WriteStartElement(“courseinfo”); // Write an XML element writer.WriteElementString(“coursename”, // Write the inner myCourse.courseName); // elements … writer.WriteEndElement(); // Close the element (well-formed)

9 More XML Parsing Goodness Throw in a few more namespaces for an even better time… Throw in a few more namespaces for an even better time… System.Xml.XPath allows a DOM tree to be parsed node by node, and even searched by level of indentation System.Xml.XPath allows a DOM tree to be parsed node by node, and even searched by level of indentation System.Xml.Xsl allows a program to load an.xsl for styling, and then output everything to.xml System.Xml.Xsl allows a program to load an.xsl for styling, and then output everything to.xml

10 More XML Parsing Features With the System.Xml.XPath namespace tacked on, With the System.Xml.XPath namespace tacked on, XmlNodeList xmlNodes; xmlNodes = xmlDoc.SelectNodes(“//courselist/course”); // Select all …individual class elements if(xmlNodes.Count > 0) foreach(XmlNode myNode in xmlNodes) { if(myNode.Type == “Element”) { myName = myNode[“coursename”].InnerText; myNum = myNode[“coursenum”].InnerText; myInstr = myNode[“instructor”].InnerText; Course temp = new Course(myName, …); …

11 Questions?