TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Thamsanqa Ngcongwane
NA
184
24.9k
How to pass XML data to Menu
Mar 4 2019 6:31 AM
This is my HTML
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
> <link rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
> <link rel=
"stylesheet"
href=
"CSS/MainStyle.css"
>
</head>
<body>
<div
class
=
"row"
> <div
class
=
"left"
style=
"background-color:#000000;"
> <h2 style=
"color:white"
>Admin</h2> <i
class
=
"fa fa-search"
></i> <input type=
"text"
id=
"mySearch"
onkeyup=
"myFunction()"
class
=
""
placeholder=
"Search"
title=
"Type in a category"
> <hr> <ul id=
"myMenu"
> <li><a href=
"#"
><i
class
=
"fa fa-fw fa-user"
></i></a></li> </ul> </div> </div>
</body> </html>
The following my Javascript
if
(window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp =
new
XMLHttpRequest(); }
else
{
// code for IE6, IE5
xmlhttp =
new
ActiveXObject(
"Microsoft.XMLHTTP"
); }
xmlhttp.open(
"GET"
,
"Data/Records.xml"
,
false
);
xmlhttp.send(
null
);
xmlDoc = xmlhttp.responseXML;
document.write(
"<ul id='myMenu'>"
);
var
x = xmlDoc.getElementsByTagName(
"record"
);
for
(i = 0; i < x.length; i++) {
document.write(
"<li><a href='"
+
"<i class='fa fa-fw fa-user'>"
+ x[i].getElementsByTagName(
"role"
)[0] .childNodes[0].nodeValue + x[i].getElementsByTagName(
"department"
)[0] .childNodes[0].nodeValue +
"</a></li>"
) ; } document.write(
"</ul>"
);
now my dta appears like this
Reply
Answers (
1
)
How to load XML data as a content on SideBar
How to get Xml to json value...