0% found this document useful (0 votes)
4 views

Beginner Tutorial - 12

The document is a tutorial on how to manipulate XML data using JavaScript, specifically focusing on changing values within an XML DOM object. It outlines the steps to create a function that modifies XML elements and demonstrates how to update the content of specific nodes. The tutorial includes code snippets and explanations for loading XML documents and iterating through their elements.

Uploaded by

Alaric Morgan
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Beginner Tutorial - 12

The document is a tutorial on how to manipulate XML data using JavaScript, specifically focusing on changing values within an XML DOM object. It outlines the steps to create a function that modifies XML elements and demonstrates how to update the content of specific nodes. The tutorial includes code snippets and explanations for loading XML documents and iterating through their elements.

Uploaded by

Alaric Morgan
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 11

1

00:00:01,300 --> 00:00:03,270


hello guys welcome back to another

2
00:00:03,270 --> 00:00:07,769
XML Dom have editorial and the speed I'm gonna show you

3
00:00:07,769 --> 00:00:11,599
how we can change at Alamance or at the

4
00:00:11,599 --> 00:00:15,130
the values inside Alamance and our

5
00:00:15,130 --> 00:00:19,199
'em XML DOM object okay

6
00:00:19,199 --> 00:00:23,859
or at some of our so I the first thing I want to do is to create

7
00:00:23,859 --> 00:00:27,939
a function and dysfunction

8
00:00:27,939 --> 00:00:31,179
is going to be called change

9
00:00:31,178 --> 00:00:34,670
and

10
00:00:34,670 --> 00:00:38,700
home here

11
00:00:38,700 --> 00:00:43,030
I'm gonna type let's see

12
00:00:43,030 --> 00:00:46,629
gonna tap in here

13
00:00:46,628 --> 00:00:51,679
I have to create a name

14
00:00:51,679 --> 00:00:55,469
I'm going to create an input type but then and

15
00:00:55,469 --> 00:00:59,859
use the on click event handler to call the function so
16
00:00:59,859 --> 00:01:03,020
do that and let's get this

17
00:01:03,020 --> 00:01:07,409
Baillieu I'll on change

18
00:01:07,409 --> 00:01:13,118
change it an

19
00:01:13,118 --> 00:01:17,009
here on click and equals

20
00:01:17,009 --> 00:01:22,519
going to be change change

21
00:01:22,519 --> 00:01:25,750
I am that's it

22
00:01:25,750 --> 00:01:29,659
function change okay

23
00:01:29,659 --> 00:01:33,079
om so in here

24
00:01:33,078 --> 00:01:38,269
I can use a parameter as well so im here im gonna time

25
00:01:38,269 --> 00:01:42,519
text and now

26
00:01:42,519 --> 00:01:47,039
what I have to do first is to create

27
00:01:47,040 --> 00:01:50,770
variable and

28
00:01:50,769 --> 00:01:55,989
some repairable and call

29
00:01:55,989 --> 00:02:02,468
the object which is load little XML doc

30
00:02:02,468 --> 00:02:05,578
so here I'm gonna say XML

31
00:02:05,578 --> 00:02:11,038
on doc is

32
00:02:11,038 --> 00:02:14,639
equal to load

33
00:02:14,639 --> 00:02:21,639
XML doc

34
00:02:21,759 --> 00:02:24,739
the file is Tom Dart XML says the file

35
00:02:24,739 --> 00:02:28,900
this is our XML file here

36
00:02:28,900 --> 00:02:32,390
I am I have created and your book

37
00:02:32,389 --> 00:02:36,628
okay so I have not too different elements or two different books

38
00:02:36,628 --> 00:02:43,408
and everyday tellin and every day job so you can create two different books okay

39
00:02:43,408 --> 00:02:46,818
because we will need to prove

40
00:02:46,818 --> 00:02:50,530
that our code works so let's proceed

41
00:02:50,530 --> 00:02:54,280
and now let's create another preval

42
00:02:54,280 --> 00:02:58,150
X equal to

43
00:02:58,150 --> 00:03:02,489
XML doc

44
00:03:02,489 --> 00:03:09,489
dart get

45
00:03:10,689 --> 00:03:13,329
elements

46
00:03:13,330 --> 00:03:19,560
by

47
00:03:19,560 --> 00:03:20,650
take name

48
00:03:20,650 --> 00:03:24,390
you don't forget this these are case sensitive you have to put

49
00:03:24,389 --> 00:03:27,699
the capital letters at the

50
00:03:27,699 --> 00:03:31,909
are supposed to be K and now

51
00:03:31,909 --> 00:03:38,909
here i just i title first time at all

52
00:03:39,860 --> 00:03:43,519
and child notes

53
00:03:43,519 --> 00:03:48,890
capital an okay and

54
00:03:48,889 --> 00:03:53,268
0 as well K now

55
00:03:53,269 --> 00:03:57,310
I am here you have to put

56
00:03:57,310 --> 00:04:01,449
something like X

57
00:04:01,449 --> 00:04:05,128
dot note

58
00:04:05,128 --> 00:04:09,578
value equals um

59
00:04:09,579 --> 00:04:14,219
to text K text is the parameters
60
00:04:14,219 --> 00:04:17,788
so this is where we say what typeof

61
00:04:17,788 --> 00:04:21,349
attacks we want to put in the node value K

62
00:04:21,350 --> 00:04:24,430
that's basically what we are sane in here

63
00:04:24,430 --> 00:04:29,259
I am obviously we will define whatever we want to

64
00:04:29,259 --> 00:04:32,839
thank you I'm or change in the tax

65
00:04:32,839 --> 00:04:36,119
in here okay later so now

66
00:04:36,120 --> 00:04:41,530
a I can say this and now to prove

67
00:04:41,529 --> 00:04:44,799
that I really change a the code

68
00:04:44,800 --> 00:04:49,060
okay the sorry the element title

69
00:04:49,060 --> 00:04:53,259
and I'm going to try to change everyday talent to you

70
00:04:53,259 --> 00:04:57,939
something else too whatever I want I am

71
00:04:57,939 --> 00:05:02,779
so what I'm going to do this a code that we already did in the last video that

72
00:05:02,779 --> 00:05:03,149
will

73
00:05:03,149 --> 00:05:06,918
loop through I'm the

74
00:05:06,918 --> 00:05:10,069
the titles and the file and will
75
00:05:10,069 --> 00:05:14,759
output the mall okay and the web page so you will you will see whatever

76
00:05:14,759 --> 00:05:18,089
I want to change I am

77
00:05:18,089 --> 00:05:22,049
everyday tellin a from or two

78
00:05:22,050 --> 00:05:25,620
so I will try to change this every day to

79
00:05:25,620 --> 00:05:28,769
I'm going to put every day USA okay

80
00:05:28,769 --> 00:05:32,348
so you'll see the output the everyday USA

81
00:05:32,348 --> 00:05:36,329
and everyday job okay so

82
00:05:36,329 --> 00:05:39,408
I can just come up in here and say

83
00:05:39,408 --> 00:05:43,288
every

84
00:05:43,288 --> 00:05:46,879
day USA okay

85
00:05:46,879 --> 00:05:50,728
and now

86
00:05:50,728 --> 00:05:56,060
I I can putting here I have to

87
00:05:56,060 --> 00:05:59,069
start the loop okay

88
00:05:59,069 --> 00:06:02,490
so the first thing I want to do is create a parable

89
00:06:02,490 --> 00:06:06,038
I why that

90
00:06:06,038 --> 00:06:09,788
is going to Whole the elements by taking the name

91
00:06:09,788 --> 00:06:13,199
title so I can cut BP's

92
00:06:13,199 --> 00:06:19,120
p based

93
00:06:19,120 --> 00:06:22,750
so all elements with title I want all

94
00:06:22,750 --> 00:06:27,319
elements that have title and now save

95
00:06:27,319 --> 00:06:31,038
for for

96
00:06:31,038 --> 00:06:34,779
I equals 0 and

97
00:06:34,779 --> 00:06:38,968
and II as class then

98
00:06:38,968 --> 00:06:44,959
why dark plank and

99
00:06:44,959 --> 00:06:49,949
I am I plus plus curly braces

100
00:06:49,949 --> 00:06:54,598
an here I'm gonna say IOM

101
00:06:54,598 --> 00:06:58,408
alert and here

102
00:06:58,408 --> 00:07:03,259
outside why a

103
00:07:03,259 --> 00:07:06,478
why I and child

104
00:07:06,478 --> 00:07:12,258
notes

105
00:07:12,259 --> 00:07:15,729
chive modes 0 and no

106
00:07:15,728 --> 00:07:19,050
a value

107
00:07:19,050 --> 00:07:22,160
and then I can type your pus

108
00:07:22,160 --> 00:07:25,639
line break

109
00:07:25,639 --> 00:07:30,389
K perfect so

110
00:07:30,389 --> 00:07:34,060
I think that's pretty much it okay we are ready the

111
00:07:34,060 --> 00:07:37,139
I'm going to loop through all the mmm

112
00:07:37,139 --> 00:07:41,210
elements the by tech name title

113
00:07:41,209 --> 00:07:45,758
okay I am and the values at them

114
00:07:45,759 --> 00:07:49,870
okay so I would probably get

115
00:07:49,870 --> 00:07:53,639
I should get an alert box saying everyday

116
00:07:53,639 --> 00:07:58,780
USA which is the first one

117
00:07:58,779 --> 00:08:02,978
as the one that I want to change and you if you pay attention

118
00:08:02,978 --> 00:08:06,060
a a chance I want I change that
119
00:08:06,060 --> 00:08:09,449
because I mention it here 0 is the first one okay

120
00:08:09,449 --> 00:08:13,360
if I wanted to change the last the second one I would put here

121
00:08:13,360 --> 00:08:17,050
1 okay so say

122
00:08:17,050 --> 00:08:21,050
this and some everyday USA

123
00:08:21,050 --> 00:08:25,009
that's pretty much it that's right and see if it works K

124
00:08:25,009 --> 00:08:28,689
so let's Randerson Firefox

125
00:08:28,689 --> 00:08:31,810
and IOM

126
00:08:31,810 --> 00:08:35,979
like it and there it is everyday USA

127
00:08:35,979 --> 00:08:40,038
and a break okay doesn't work

128
00:08:40,038 --> 00:08:43,509
every day job doesn't appear in the same message box

129
00:08:43,509 --> 00:08:46,870
so what I'm good do is change a little bit

130
00:08:46,870 --> 00:08:50,269
this one this thing here

131
00:08:50,269 --> 00:08:54,559
let's change this and put a document

132
00:08:54,559 --> 00:08:58,359
right as we did in the last video

133
00:08:58,360 --> 00:09:01,860
more presentable and
134
00:09:01,860 --> 00:09:05,970
here document

135
00:09:05,970 --> 00:09:10,940
right and no

136
00:09:10,940 --> 00:09:16,010
BR perfect

137
00:09:16,009 --> 00:09:19,730
save it I let's run this

138
00:09:19,730 --> 00:09:24,240
for parks K it is

139
00:09:24,240 --> 00:09:27,490
quick it and their this everyday USA

140
00:09:27,490 --> 00:09:31,649
and every day job perfect okay if I i

141
00:09:31,649 --> 00:09:36,448
change this to you another that's it here

142
00:09:36,448 --> 00:09:40,189
every day Spain

143
00:09:40,190 --> 00:09:43,650
or whatever you want to do

144
00:09:43,649 --> 00:09:47,208
there I would just come up games

145
00:09:47,208 --> 00:09:54,208
year run it and and

146
00:09:54,389 --> 00:09:57,588
click it and their deaths every day Spain everyday Joe

147
00:09:57,589 --> 00:10:01,520
okay so you see a how that we can

148
00:10:01,519 --> 00:10:05,860
their change whatever elements we want and our

149
00:10:05,860 --> 00:10:09,500
on XML okay so this is it for now

150
00:10:09,500 --> 00:10:11,070
and see you guys next to you by

You might also like