Working with xml on a web site.

I am working with xml file dump from are ad server.

<?xml version="1.0" encoding="UTF-8"?>

<Information Technology>
	<user>

    	<Name>Jim Lin</Name>
    	<Title>Application and Systems Supp. Spec.</Title>
    	<Department>Information Technology</Department>
    	<Extension>5555</Extension>
    	<Mobile Number>555-555-55555</Mobile Number>
    	<Office Location>Sylvan</Office Location>
    	<Email Address>jlin@google.com</Email Address>
    	<Username>jlin</username>
    	<Manager>Bob Arm</Manager>

	</user>

	<user>

    	<Name>John Smith</Name>
    	<Title>Network Admin.</Title>
    	<Department>Information Technology</Department>
    	<Extension>6666</Extension>
    	<Mobile Number>666-666-6666</Mobile Number>
    	<Office Location>Sylvan</Office Location>
    	<Email Address>jsmith@google.com</Email Address>
    	<Username>jsmith</username>
    	<Manager>Bob Arm</Manager>

	<user>

</Information Technology>

Open in new window


You get the idea I want to display this info on a web page that runs locally on the users laptop. There is no web server on the laptop and it's in not connect to the internet.

It does have java installed. How can i have this info displayed in a web browser
armasmikeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nap0leonCommented:
Hopefully that is not the actual XML... way too many errors in it for it to work properly (mismatched case in the xml tags, spaces in the tag values, etc.).

To load the XML from a file:
http://www.w3schools.com/dom/dom_loadxmldoc.asp
function loadXMLDoc(filename)
{
if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else // code for IE5 and IE6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
} 
var xmlDoc=loadXMLDoc("books.xml");

Open in new window


To load XML from a string (in case you are importing it as text)
http://www.w3schools.com/dom/dom_loadxmldoc.asp
function loadXMLString(txt)
{
if (window.DOMParser)
  {
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(txt,"text/xml");
  }
else // code for IE
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.loadXML(txt);
  }
return xmlDoc;
}
var xmlDoc=loadXMLString(text);

Open in new window


To get values from the XML once you load it into a variable:
http://www.w3schools.com/dom/dom_methods.asp

Then you loop through it to get what you need.
e.g., to get the name of the first user:
function loadXMLString(txt)
{
if (window.DOMParser)
  {
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(txt,"text/xml");
  }
else // code for IE
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.loadXML(txt);
  }
return xmlDoc;
}

text= "<InformationTechnology>"
text+= "<user>"
text+= "<Name>Jim Lin</Name>"
text+= "<Title>Application and Systems Supp. Spec.</Title>"
text+= "<Department>Information Technology</Department>"
text+= "<Extension>5555</Extension>"
text+= "<MobileNumber>555-555-55555</MobileNumber>"
text+= "<OfficeLocation>Sylvan</OfficeLocation>"
text+= "<EmailAddress>jlin@google.com</EmailAddress>"
text+= "<Username>jlin</Username>"
text+= "<Manager>Bob Arm</Manager>"
text+= "</user>"
text+= "<user>"
text+= "<Name>John Smith</Name>"
text+= "<Title>Network Admin.</Title>"
text+= "<Department>Information Technology</Department>"
text+= "<Extension>6666</Extension>"
text+= "<MobileNumber>666-666-6666</MobileNumber>"
text+= "<OfficeLocation>Sylvan</OfficeLocation>"
text+= "<EmailAddress>jsmith@google.com</EmailAddress>"
text+= "<Username>jsmith</Username>"
text+= "<Manager>Bob Arm</Manager>"
text+= "</user>"
text+= "</InformationTechnology>"

var xmlDoc=loadXMLString(text);


xmlDoc.getElementsByTagName("InformationTechnology")[0].getElementsByTagName("user")[0].getElementsByTagName("Name")[0].childNodes[0].nodeValue

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Walter PadrónCommented:
With XSLT you can transform an XML document into HTML, no web server needed but some CSS knowledge is necessary.
see http://www.w3schools.com/xml/xml_xsl.asp for an example
0
armasmikeAuthor Commented:
thank you
0
nap0leonCommented:
armasmike - if you are not limited to using only JavaScript, you should definitely look into using XSLT as Walter suggested.  

There's a bit of a learning curve, especially if you want to do anything super fancy with it, but it may present additional flexibility in presenting the information on your page.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.