473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML output in HTML using DOM

25 New Member
HI!

I am using XML file to give HTML output using DOM.

the files i am using is

<bookstore>
<book category="COOKI NG" id="10001">
<title lang="en">Every day Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILD REN" id="10002">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB" id="10003">
<title lang="en">XQuer y Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyan athan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB" id="10004">
<title lang="en">Learn ing XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>


Now I need an output in HTML file using DOM to get the attribute name i.e. 'id' for getElementsByTa gName("book") in an HTML tag
<tr><th>Book ID</th></tr>
<tr><td>10001 </td></tr>
Feb 5 '08 #1
3 1275
jkmyoung
2,057 Recognized Expert Top Contributor
http://www.w3schools.c om/dom/prop_element_at tributes.asp

x=xmlDoc.getEle mentsByTagName( "book")[0].attributes.get NamedItem("id") ;
Feb 5 '08 #2
rupak
25 New Member
http://www.w3schools.c om/dom/prop_element_at tributes.asp

x=xmlDoc.getEle mentsByTagName( "book")[0].attributes.get NamedItem("id") ;
It is not what i want, It will return the value of the attribute 'id'. I am looking to get the attribute 'id' if present i.e. to check if the attribute is present in the tag or not then print the attribute name modified with text "BOOK ID" then in next row get the value of the attribute.
Feb 6 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
Could I see what you have at the moment, and what output you are getting?
Feb 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2111
by: Taare | last post by:
Hi, I got <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system=" http://www.w3.org/TR/html4/strict.dtd"/> in my XSLT file. This should remove all XML related code and replace with HTML valid code, but with my commandline XSLT transformer(http://xmlsoft.org/XSLT/) it outputs a xmlns on elements I'v used <xsl:copy-of select="/some/node"> to produce. Is this how it should work, or is this...
6
3035
by: Sharon | last post by:
Hi! I'm trying to add an export option to my application. I use Javascript DOM to transform XHTML-tables displayed in the browser window to CSV-format (client-side) using a simple XSL. All works fine, except that I can't seem to get any further than alerting the output *sigh*... Who can give me hints on how to get the output to the client somehow? Should I save it to the server first and then allow the client to get it from there, or can...
3
1736
by: danmc91 | last post by:
Hi, I'm just getting going with xml and xslt. I'm trying to write what are essentially man pages and I need 3 output formats. 1) nroff -man format for real man pages 2) html for an online help browser 3) ascii where every line must start with a '%' character (octave
6
4260
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I perform actions with php/CURL the output is different than when I use IE and I'm completely stumped as to why. The final output should list files available for retrieval but the CURL output displays an error/empty file message. Here is the curl...
2
4371
by: Hawk | last post by:
I have a custom menu control that I am creating using C#. I am rendering HTML from a StringBuilder in my control to add the needed JavaScript to the HTML output. I need to have the JavaScript output from the stringbuilder placed at the bottom of my <BODY> section, after the top navigation menu dropdown dataset output. Currently the JavaScript is output to the top of the <BODY> section of my HTML output from the control. How can I...
5
1732
by: Brad | last post by:
I created a base page class which sets a response filter and the filter injects additional html into the response output stream. The filter works fine and everything works as expected except for the following quirk: When I navigate my browser to another url (a link in the page, a browser favorite...it doesn't mater) and then use the browsers (IE 6) Back or Forward buttons to go back to my filtered page the additional html I had added...
1
1936
by: Henry Nelson | last post by:
Hi all I'm very new to dotNet and just trying to get my head around the right way to do the thing that I would normally do in asp. In asp I would loop through a recordset and output all the html dynamically for the layout I want. I have seen some examples of using a repeater and they seem to be the thing to use when you don't want a table of results, but I'm not sure how to change the <ItemTemplate> depending on the contents of the...
1
4348
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy part, but I couldn't initially work out how to manipulate the page setup to change page margins and orientation, that's why I was looking at Microsoft.Office.Interop. But with Microsoft.Office.Interop I couldn't fiure out how to stream HTML...
3
2372
by: bloc | last post by:
I am programming an interactive CV using xml, xslt and java script. The page consists of a header which contains links to various 'sections' on the xml cv, a left and right menu, and a central panel. The central panel is intended to display the main content of the cv: when an anchor is selected from the header then the detail is supposed to appear. The javascript is supposed to select the appropriate section 'onclick' and output it....
4
3372
by: Jon Slaughter | last post by:
I'm using eval to excute some mixed php and html code but I cannot debug it. I am essentially using filegetcontents to load up a php/html file and then inserting it into another php/html file and then using eval to execute the final product. If I were to use include and output buffering instead of filegetcontents would it allow be to debug the code? (I have to capture the include so it can be modified which is why I used...
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.