Beginner Tutorial - 10
Beginner Tutorial - 10
2
00:00:03,908 --> 00:00:07,369
XML chapter and this lady I'm gonna talk about the
3
00:00:07,370 --> 00:00:11,839
XML Dom so pretty much as JavaScript
4
00:00:11,839 --> 00:00:16,350
I XML also has Dom and in the DOM
5
00:00:16,350 --> 00:00:19,429
and XML everything is and note
6
00:00:19,429 --> 00:00:24,100
so week old notes to I have a little
7
00:00:24,100 --> 00:00:27,190
map here show you Curtis
8
00:00:27,190 --> 00:00:30,910
so we have a route element
9
00:00:30,910 --> 00:00:36,759
and net which is the bookstore and it's the parent then we have the child's
10
00:00:36,759 --> 00:00:39,818
which is the them the book
11
00:00:39,819 --> 00:00:43,739
category title author this is how
12
00:00:43,738 --> 00:00:46,738
a DOM a is presented a DOM
13
00:00:46,738 --> 00:00:49,838
note tree is present in and
14
00:00:49,838 --> 00:00:53,568
alva an XML file now
15
00:00:53,569 --> 00:00:57,139
I'm gonna grab this all these elements
16
00:00:57,139 --> 00:01:00,429
or all these notes and create
17
00:01:00,429 --> 00:01:03,510
an XML file from this map
18
00:01:03,509 --> 00:01:06,599
okay so you can have a
19
00:01:06,599 --> 00:01:11,599
clear idea how this all works so the first thing is create
20
00:01:11,599 --> 00:01:15,039
the you see have bookstore
21
00:01:15,040 --> 00:01:19,480
as a parent or route element so the first thing
22
00:01:19,480 --> 00:01:23,530
the first thing I'm gonna create your is book
23
00:01:23,530 --> 00:01:28,840
store K and I'm gonna close it down here
24
00:01:28,840 --> 00:01:34,310
make sure we have the XML
25
00:01:34,310 --> 00:01:39,060
version at the top the file and
26
00:01:39,060 --> 00:01:42,310
them now the next thing is
27
00:01:42,310 --> 00:01:45,760
create a.m. book
28
00:01:45,760 --> 00:01:51,590
element book
29
00:01:51,590 --> 00:01:58,590
so let's hope you book down here let's close this
30
00:02:01,250 --> 00:02:07,090
now insight here inside book now we have
31
00:02:07,090 --> 00:02:10,750
let me check we have arm
32
00:02:10,750 --> 00:02:14,199
title Arthur year and price as child's
33
00:02:14,199 --> 00:02:17,229
book if the element book so
34
00:02:17,229 --> 00:02:20,849
thats what we gonna do as child's here
35
00:02:20,849 --> 00:02:25,069
you can call a child's or notes okay everything and is a note
36
00:02:25,069 --> 00:02:28,359
okay every single tag here is a note
37
00:02:28,360 --> 00:02:31,420
a.m. now
38
00:02:31,419 --> 00:02:37,098
let's tie title
39
00:02:37,098 --> 00:02:42,030
here of her that's close
40
00:02:42,030 --> 00:02:48,650
after the next one was a year this
41
00:02:48,650 --> 00:02:52,379
now is price that Prince
42
00:02:52,379 --> 00:02:55,689
price
43
00:02:55,689 --> 00:03:00,370
now the title was
44
00:03:00,370 --> 00:03:03,549
um check okay
45
00:03:03,549 --> 00:03:08,500
every day Italian
46
00:03:08,500 --> 00:03:12,060
the offer was geodata
47
00:03:12,060 --> 00:03:16,348
you was 2005 pan
48
00:03:16,348 --> 00:03:20,289
30 bucks now
49
00:03:20,289 --> 00:03:23,810
we have attributes as well we have
50
00:03:23,810 --> 00:03:27,120
net reviewed language and match reviews category
51
00:03:27,120 --> 00:03:31,549
the categories that attribute for element book so what we gonna do
52
00:03:31,549 --> 00:03:35,170
is here tie category
53
00:03:35,169 --> 00:03:38,768
equals and here we can tire farm
54
00:03:38,769 --> 00:03:44,189
see romance to type anything that has to do
55
00:03:44,189 --> 00:03:49,250
related to the the book itself so we also have
56
00:03:49,250 --> 00:03:52,579
a.m. and attributes: language
57
00:03:52,579 --> 00:03:56,409
that goes
58
00:03:56,409 --> 00:03:59,479
and the title here
59
00:03:59,479 --> 00:04:02,548
okay language equals the
60
00:04:02,549 --> 00:04:05,739
and so it's gonna be E
61
00:04:05,739 --> 00:04:10,319
and for English okay so a
62
00:04:10,318 --> 00:04:14,619
you can save this s bookstore dot AXA Mount Isa size they did
63
00:04:14,620 --> 00:04:17,959
and if you see the map
64
00:04:17,959 --> 00:04:22,098
here everything in that is in here
65
00:04:22,098 --> 00:04:26,449
is now in this Dom no tree is now presented
66
00:04:26,449 --> 00:04:30,639
as an XML normal file in here
67
00:04:30,639 --> 00:04:34,680
a good this is what we know and how to do
68
00:04:34,680 --> 00:04:37,889
and this is how it's presented
69
00:04:37,889 --> 00:04:41,400
and as a DOM node tree now
70
00:04:41,399 --> 00:04:44,978
I'm gonna show you how bout to
71
00:04:44,978 --> 00:04:48,209
IOM access every single
72
00:04:48,209 --> 00:04:51,769
element in and note or
73
00:04:51,769 --> 00:04:55,500
dunno tree a with JavaScript
74
00:04:55,500 --> 00:05:01,079
and also we gonna use XHTML so basically what we gonna do is
75
00:05:01,079 --> 00:05:04,589
let's say we have now at the bookstore dot XML
76
00:05:04,589 --> 00:05:09,279
and we have some bunch information other books
77
00:05:09,279 --> 00:05:13,679
in here and it's basically
78
00:05:13,680 --> 00:05:17,918
like a a meanie database and I'm gonna show you how to access
79
00:05:17,918 --> 00:05:21,649
that database that we have in the XML
80
00:05:21,649 --> 00:05:24,879
all the information we have in the XML file with
81
00:05:24,879 --> 00:05:30,038
an exceptional document and some javascript okay so first the ball
82
00:05:30,038 --> 00:05:33,089
create the named extort HTML
83
00:05:33,089 --> 00:05:36,679
the normal texts of 'em
84
00:05:36,680 --> 00:05:41,800
assertion of I'll now let's talk to script X
85
00:05:41,800 --> 00:05:48,800
so we can start to end some JavaScript
86
00:05:52,579 --> 00:05:57,800
and close it here
87
00:05:57,800 --> 00:06:01,430
okay now I'm gonna show you block of code
88
00:06:01,430 --> 00:06:04,759
have JavaScript that we always use the
89
00:06:04,759 --> 00:06:08,170
whenever we want to load an XML file to
90
00:06:08,170 --> 00:06:11,970
annexation of page okay and this is the co
91
00:06:11,970 --> 00:06:15,550
I already created goat previously and
92
00:06:15,550 --> 00:06:19,030
I'm gonna explain now line by line what this all means
93
00:06:19,029 --> 00:06:23,299
from here at the top we have
94
00:06:23,300 --> 00:06:26,300
NFL's condition which basically will
95
00:06:26,300 --> 00:06:29,680
I make sure a or confirm
96
00:06:29,680 --> 00:06:32,730
if the user is using Internet Explorer
97
00:06:32,730 --> 00:06:36,420
or at their tap a browser like Chrome or Firefox
98
00:06:36,420 --> 00:06:40,670
or Safari if the user is using Internet Explorer
99
00:06:40,670 --> 00:06:44,439
we create affair bill called X ish to be
100
00:06:44,439 --> 00:06:47,930
which will have this value which is a
101
00:06:47,930 --> 00:06:51,189
Microsoft XML ish to be object
102
00:06:51,189 --> 00:06:54,800
okay this isn't the case that the user is used in Internet Explorer
103
00:06:54,800 --> 00:06:57,900
if it's not use an Internet Internet Explorer
104
00:06:57,899 --> 00:07:01,529
and it's using other type of browser we
105
00:07:01,529 --> 00:07:04,949
a.m. have a given the value love
106
00:07:04,949 --> 00:07:08,360
XML h2b request object
107
00:07:08,360 --> 00:07:11,420
to you the variable X ish to be now
108
00:07:11,420 --> 00:07:14,590
dissident if else condition is the
109
00:07:14,589 --> 00:07:18,489
basically to check if there is Internet Explorer
110
00:07:18,490 --> 00:07:21,600
are not and the Penza the browser that
111
00:07:21,600 --> 00:07:26,030
the users using we will use the a different object either the Microsoft
112
00:07:26,029 --> 00:07:26,659
object
113
00:07:26,660 --> 00:07:31,720
or a normal object to request information to the SIR
114
00:07:31,720 --> 00:07:35,070
now we grab now the
115
00:07:35,069 --> 00:07:39,370
X ish could be here that we've given at the objects
116
00:07:39,370 --> 00:07:42,530
value we grab it and type it
117
00:07:42,529 --> 00:07:45,750
here and type dot open
118
00:07:45,750 --> 00:07:48,990
okay dis the method that will have 3
119
00:07:48,990 --> 00:07:52,050
a.m. values here to get
120
00:07:52,050 --> 00:07:56,629
okay and Dan the name of the XML file you want to load
121
00:07:56,629 --> 00:08:00,250
okay in this case is bookstore here
122
00:08:00,250 --> 00:08:05,279
this the are XML file and at the end you type always false
123
00:08:05,279 --> 00:08:09,369
locate this make sure you have false otherwise we'll have problems
124
00:08:09,370 --> 00:08:13,350
now we use again the variable X ish to be
125
00:08:13,350 --> 00:08:16,710
and use the method send so
126
00:08:16,709 --> 00:08:20,599
we send an exe their an XML HTTP request sorry
127
00:08:20,600 --> 00:08:24,280
to server or to the server
128
00:08:24,279 --> 00:08:28,429
an dan we set the response as an XML
129
00:08:28,430 --> 00:08:31,810
Dom object a in the very well XML
130
00:08:31,810 --> 00:08:36,279
doc okay now at the end
131
00:08:36,279 --> 00:08:40,750
to you make sure that everything is working fine and the XML
132
00:08:40,750 --> 00:08:44,799
file has been loaded and parsed
133
00:08:44,799 --> 00:08:48,299
a we create document.write and then
134
00:08:48,299 --> 00:08:52,259
XML type whatever you want here but I created here
135
00:08:52,259 --> 00:08:56,700
a.m. to XML document loaded
136
00:08:56,700 --> 00:09:00,690
into an XML DOM object or you can type XML document
137
00:09:00,690 --> 00:09:03,760
or XML file loaded the
138
00:09:03,759 --> 00:09:06,759
and ready something like that so
139
00:09:06,759 --> 00:09:10,000
now TTU checked that everything is working fine
140
00:09:10,000 --> 00:09:13,649
and we are ready to create some more jobs script
141
00:09:13,649 --> 00:09:16,990
to output the failures that we have here
142
00:09:16,990 --> 00:09:20,250
because XML all the elements
143
00:09:20,250 --> 00:09:23,409
then or all the nodes and information that we have
144
00:09:23,409 --> 00:09:27,009
and XML file will be a.m.
145
00:09:27,009 --> 00:09:30,240
we will be able to output them and XML
146
00:09:30,240 --> 00:09:34,820
XHTML page so basically XML will
147
00:09:34,820 --> 00:09:39,390
be like a meanie MySQL database to hold information
148
00:09:39,389 --> 00:09:44,100
and then with JavaScript JavaScript will
149
00:09:44,100 --> 00:09:48,240
workers Beach be more or less like beach be to use
150
00:09:48,240 --> 00:09:53,340
output information remember in BHP chapter that we use PHP
151
00:09:53,340 --> 00:09:56,980
to you output and replace in
152
00:09:56,980 --> 00:10:00,090
update and delete information from the MySQL database
153
00:10:00,090 --> 00:10:03,620
so this is pretty much the same thing a.m.
154
00:10:03,620 --> 00:10:09,409
but instead a PHP will use JavaScript and instead of MySQL database will use
155
00:10:09,409 --> 00:10:12,600
a an XML file and
156
00:10:12,600 --> 00:10:15,690
some gonna show you all that and a few next videos
157
00:10:15,690 --> 00:10:19,180
I hard to delete a output
158
00:10:19,179 --> 00:10:24,000
and update information a data stored internet and
159
00:10:24,000 --> 00:10:29,279
XML file an for now if you want to see if this works
160
00:10:29,279 --> 00:10:32,740
and if you want to see that
161
00:10:32,740 --> 00:10:35,839
the document right and this well be outputted
162
00:10:35,839 --> 00:10:39,670
and the page if you go here and run it
163
00:10:39,669 --> 00:10:40,149
and
164
00:10:40,149 --> 00:10:44,709
in Firefox it will work
165
00:10:44,710 --> 00:10:48,470
okay you have here the XML
166
00:10:48,470 --> 00:10:51,800
document loaded international
167
00:10:51,799 --> 00:10:55,599
object but if you tried in chrome
168
00:10:55,600 --> 00:10:58,639
nuffin will appear why
169
00:10:58,639 --> 00:11:02,470
because chrome a.m. is not
170
00:11:02,470 --> 00:11:06,000
I am I'm sorry I am
171
00:11:06,000 --> 00:11:11,360
the send request information or the objects that you use in here
172
00:11:11,360 --> 00:11:16,860
are not and a server and basically we are sending information to a server but
173
00:11:16,860 --> 00:11:18,980
we are not working on a server so
174
00:11:18,980 --> 00:11:23,629
we have to use these files and and the
175
00:11:23,629 --> 00:11:26,789
with the that control panel and and
176
00:11:26,789 --> 00:11:31,480
HD docs more like more less like we did with php files
177
00:11:31,480 --> 00:11:34,970
so Mb check that you work in
178
00:11:34,970 --> 00:11:39,200
Apache here and
179
00:11:39,200 --> 00:11:43,129
lemme hood the files
180
00:11:43,129 --> 00:11:46,500
bookstore dot XML and index thought HTML
181
00:11:46,500 --> 00:11:50,429
I've with them and test XML folder
182
00:11:50,429 --> 00:11:53,429
now I'm going to put this folder inside HE docs
183
00:11:53,429 --> 00:11:56,439
and I'm using
184
00:11:56,440 --> 00:11:59,510
chrome again but now if I go to
185
00:11:59,509 --> 00:12:03,019
local host and type
186
00:12:03,019 --> 00:12:07,059
the this was called
187
00:12:07,059 --> 00:12:11,539
test XML and type test XML
188
00:12:11,539 --> 00:12:15,129
index dot shemale
189
00:12:15,129 --> 00:12:19,600
it works white because we're working on a server now
190
00:12:19,600 --> 00:12:23,730
and basically when you use when you start using
191
00:12:23,730 --> 00:12:27,300
a XML HTTP requests
192
00:12:27,299 --> 00:12:30,399
you have to be and the server and you have
193
00:12:30,399 --> 00:12:33,889
to check that everything is working fine you have to work on a server
194
00:12:33,889 --> 00:12:38,769
now make sure you are using as them control panel and Apache
195
00:12:38,769 --> 00:12:42,429
tested make sure everything is working
196
00:12:42,429 --> 00:12:46,029
and in the next few videos will learn as some
197
00:12:46,029 --> 00:12:49,470
pretty cool stuff okay so see you guys later
198
00:12:49,470 --> 00:12:49,720
I