Gu Into Reviewer
Gu Into Reviewer
to XML
Mark William Guinto
What is XML?
XML (Extensible Markup Language) is a markup language similar to HTML, but without
predefined tags to use. Instead, you define your own tags designed specifically for your
needs. This is a powerful way to store data in a format that can be stored, searched,
and shared. Most importantly, since the fundamental format of XML is standardized, if
you share or transmit XML across systems or platforms, either locally or over the
internet, the recipient can still parse the data due to the standardized XML syntax.
There are many languages based on XML, including XHTML, MathML, SVG, RSS, and
RDF. You can also define your own.
Structure of an XML document
XML declaration
XML - declaration is not a tag. It is used for the transmission of the meta-data of a document.
html
Copy to Clipboard
<?xml version="1.0" encoding="UTF-8"?>
Displaying XML
XML is usually used for descriptive purposes, but there are ways to
display XML data. If you don't define a specific way for the XML to be
rendered, the raw XML is displayed in the browser.
Many computer systems contain data in incompatible formats. Exchanging data between incompatible systems
(or upgraded systems) is a time-consuming task for web developers. Large amounts of data must be converted,
and incompatible data is often lost.
XML stores data in plain text format. This provides a software- and hardware-independent way of storing,
transporting, and sharing data.
XML also makes it easier to expand or upgrade to new operating systems, new applications, or new browsers,
without losing data.
With XML, data can be available to all kinds of "reading machines" like people, computers, voice machines, news
feeds, etc.
Example of XML File
This XML example represents a library with two books.
Here's a breakdown:
● <?xml version="1.0" encoding="UTF-8"?>: This line declares the XML version and character encoding used in the
document.
● <library>: This is the root element, encompassing all the information about the library.
● <book>: This element represents a single book in the library. It has attributes like id to uniquely identify each book.
● <title>, <author>, <genre>, <price>, <publish_date>, <description>: These are child elements of <book>
providing details about the book.
This structure demonstrates how XML uses tags to organize and label data in a hierarchical way, making it both human-readable and
machine-readable.
What is Python
● Backend Frameworks: Python offers robust frameworks like Django and Flask, which simplify web
development tasks, enabling rapid prototyping and efficient development of scalable web applications.
● APIs and Web Services: Python is excellent for building RESTful APIs, allowing different applications to
communicate with each other.
● Data Analysis and Visualization: Libraries like Pandas and NumPy provide powerful tools for data
manipulation, cleaning, and analysis. Matplotlib and Seaborn are used for creating insightful visualizations.
● Machine Learning: Python is the go-to language for machine learning, with libraries like scikit-learn offering
a wide range of algorithms for tasks like classification, regression, and clustering. TensorFlow and PyTorch
are popular for deep learning.
Python is a versatile language used in a wide range of 5
● Task Automation: Python can automate repetitive tasks, such as file management, system administration, and web scraping,
saving time and increasing efficiency.
● Scripting: Python can be used to write scripts for various purposes, like automating software testing, interacting with
databases, and managing network devices.
4. Desktop Applications:
● GUI Development: Python provides libraries like Tkinter and PyQt for creating graphical user interfaces for desktop
applications.
● Beginner-Friendly: Python's simple syntax and readability make it an ideal language for beginners to learn programming
concepts.
● Versatile Applications: Python can be used to teach various computer science concepts, from basic programming to
advanced topics like data structures and algorithms.
6
Python is a versatile language used in a wide range of
applications. Here are some of the most common and
practical uses:
6. Other Notable Uses:
These are just a few examples of the many practical uses of Python. Its versatility, extensive libraries, and active
community make it a powerful tool for a wide range of tasks.
Basic output 7
The print() function displays output to the user. Output is the information or
result produced by a program. The sep and end options can be used to customize
the output. Table 1.1 shows examples of sep and end.
By default, the print() function adds a newline character at the end of the output.
A newline character tells the display to move to the next line. The end option can
be used to continue printing on the same line.
8
Python - Lesson 8
x = 5
y = "John"
print(x)
print(y)
Variables
Variables do not need to be declared with any particular type, and can even change type after they have been
set.
x = 4 # x is of type int
print(x)
Casting
If you want to specify the data type of a variable, this can be done with casting.
y = int(3) # y will be 3
x = "John"
# is the same as
x = 'John'
Case-Sensitive
a = 4
A = "Sally"
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
illegal Variable Names
2myvar = "John"
my-var = "John"
my var = "John"
my-var = "John"
my var = "John"
print(x)
print(y)
print(z)
Global Variables
Variables that are created outside of a function (as in all of the examples in the previous pages) are known as
global variables.
Global variables can be used by everyone, both inside of functions and outside.
x = "awesome"
def myfunc():
print("Python is " + x)
myfunc()
If you create a variable with the same name inside a function, this variable will be local, and can only be
used inside the function. The global variable with the same name will remain as it was, global and with the
original value.
Create a variable inside a function, with the same name as the global variable
x = "awesome"
def myfunc():
x = "fantastic"
print("Python is " + x)
myfunc()
print("Python is " + x)
In programming, data type is an important concept.
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:
a = "Hello"
b = "World"
c = a + b
print(c)
a = "Hello"
b = "World"
c = a + " " + b
print(c)
Python Conditions and If statements
● Equals: a == b
● Not Equals: a != b
● Less than: a < b
● Less than or equal to: a <= b
● Greater than: a > b
● Greater than or equal to: a >= b
These conditions can be used in several ways, most commonly in "if statements" and
loops.
a = 33
b = 200
if b > a:
print("b is greater than a")
Indentation
Python relies on indentation (whitespace at the beginning of a line) to define scope in
the code. Other programming languages often use curly-brackets for this purpose.
a = 33
b = 200
if b > a:
print("b is greater than a") # you will get an error
Elif
The elif keyword is Python's way of saying "if the previous conditions were not true,
then try this condition".
a = 33
b = 33
if b > a:
elif a == b:
a = 200
b = 33
if b > a:
elif a == b:
else:
a = 200
b = 33
if b > a:
elif a == b:
else: