473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to call the xml in jsp

hi ,

i am using dom persor but i the jsp call xml file bt its not read that xml why.
Expand|Select|Wrap|Line Numbers
  1. <%@page import="org.w3c.dom.Node, org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.NodeList, javax.xml.parsers.DocumentBuilder, javax.xml.parsers.DocumentBuilderFactory" %>
  2.  
  3. <%!
  4.     public boolean isTextNode(Node n)
  5.   {
  6.     return n.getNodeName().equals("#text");
  7.   }
  8. %>
  9.  
  10.    <%      
  11.       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  12.       DocumentBuilder        builder = factory.newDocumentBuilder();
  13.       Document doc = builder.parse("D://xmldoc/testmht.xml");          
  14.    %>     
  15.  
  16.   <%    
  17.            Element  root = doc.getDocumentElement(); 
  18.          NodeList sm_resultsNodes = root.getChildNodes();    
  19.  
  20.       for (int i=0; i<sm_resultsNodes.getLength(); i++)
  21.       {
  22.         Node currentsm_results = sm_resultsNodes.item(i);
  23.  
  24.  
  25.         NodeList originatorAndOriginatorGW  = currentsm_results.getChildNodes(); 
  26.     %>
  27.  
  28.     <tr>    
  29.  
  30.     <%
  31.         for (int j=0; j<originatorAndOriginatorGW.getLength(); j++ )
  32.         {
  33.           Node currentItem = originatorAndOriginatorGW.item(j);
  34.  
  35.           if ( isTextNode(currentItem)) 
  36.            continue;
  37.     %>
  38.       <td><%= currentItem.getFirstChild().getNodeValue() %></td>
  39.     <%
  40.         } 
  41.     %>
  42.     </tr>
  43.  
  44.     <%
  45.       } 
  46.     %>
Dec 31 '07 #1
1 2225
jkmyoung
2,057 Expert 2GB
At what point does your code break?

What results if any are you getting? Error messages?
Jan 3 '08 #2

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

Similar topics

23
by: Fabian Müller | last post by:
Hi all, my question is as follows: If have a class X and a class Y derived from X. Constructor of X is X(param1, param2) . Constructor of Y is Y(param1, ..., param4) .
35
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
5
by: Amaryllis | last post by:
I'm trying to call a CL which is located on our AS400 from a Windows application. I've tried to code it in different ways, but I seem to get the same error every time. Does anyone have any clue...
13
by: mitchellpal | last post by:
i am really having a hard time trying to differentiate the two..........i mean.....anyone got a better idea how each occurs?
13
by: shsingh | last post by:
I have a class A containing some map as data variables. I creat an object of class A on heap by allocatiing memory by using "malloc". This will return me the required memory but the object is not...
3
by: cberthu | last post by:
Hi all, Is it possible to have two connects in the same rexx script to different DB's? I have to get data form on DB (with specifics selects and filter out some values with RExx) and save the...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
12
by: Rahul | last post by:
Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.