kalyan kiran

Greenhorn
+ Follow
since Aug 21, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kalyan kiran

I have a user who logs in and wants to send messages to 3 different users and the mesage should appear to them when ever he logs in if he is already present he shold receive an instant message and should be able to send the message back to the person who has sent what is the best of doing this
22 years ago
Hi,
I Want to know whether a file is properly downloaded or not
at client side from server and also i would like to know how many bytes are being downloaded and i wil be very happy if any one of u can give me a sample code for downloading a file,
my client side is html page and middle tier is a servelt .pls reply me immediately
22 years ago
Hi,
I ma unable to delete and update a record in the xml file till now using jaxp. I am using a dom parser .
I have generated on xm file but name say m_layout.xml from the database values. the xml file looks like this.
<xml><records="3"><record row ="1"><header_id>head</header_id>
<lenght>3</length></record>
<record row="2"><header_id>jpsin</header_id><length>4</length>
</record>
<record row="3"><header_id>xxx</header_id><lenght>5</length>
</record>
</records></xml>
This is the structure of my xml. now suppose i want to modify first record in xml . how do i do that through dom and how do i write it back into file as what ever changes are made through dom they will be in memory only. i am psting the code what ever i have writeen please give me some feed back for tdeleting updating and appending records
code
----
package dfm;
import org.w3c.dom.*;
import com.sun.xml.tree.*;
import org.xml.sax.SAXException;
import java.io.*;
import java.util.*;
public class Parser
{
String filename="";
Document doc=null;
NodeList nodelist=null, nodelist1 = null,nodelist2 = null;
Node node=null, node1 = null,node2 = null;
NamedNodeMap map1=null;

public HashMap getHashMap()
{
int length = 0;
HashMap columnNames = new HashMap();
columnNames.put("*",filename.toUpperCase());
nodelist=doc.getElementsByTagName("record");
node = nodelist.item(0);
System.out.println(node.getNodeValue());
nodelist1 = node.getChildNodes();
length = nodelist1.getLength();

for(int j = 0 ; j < length ; j++)
{
node1 = nodelist1.item(j);
System.out.println(node1.getNodeName());
columnNames.put(node1.getNodeName(),new Integer(j+1));
}

return columnNames;
}
public Parser(String filename)
{
this.filename = filename;
try
{
InputStream instream=new FileInputStream(filename);
doc = XmlDocument.createXmlDocument(instream,false);
}
catch(Exception e){e.printStackTrace();}
}
public Vector getVector()
{
int len = 0,length = 0;
Vector data = new Vector();
int rowCnt = 0;
try
{
nodelist=doc.getElementsByTagName("record");
len=nodelist.getLength();
for(int i=0;i<len;i++)
{
node = nodelist.item(i);
nodelist1 = node.getChildNodes();
length = nodelist1.getLength();
String[] currentRow = new String[length+1];
for(int j = 0 ; j < length ; j++)
{

node1 = nodelist1.item(j);
currentRow[j+1] = node1.getChildNodes().item(0).getNodeValue();
}
data.addElement(currentRow);
rowCnt++;
}
}
catch(Exception e){e.printStackTrace();}
return data;
}
public Vector getLayoutids(String extendedFlag)
{
int len = 0,length = 0;
Vector data = new Vector();
try
{
nodelist=doc.getElementsByTagName("record");
len=nodelist.getLength();
for(int i=0;i<len;i++)
{
node = nodelist.item(i);
nodelist1 = node.getChildNodes();
node1 = nodelist1.item(1);
if(node1.getChildNodes().item(0).getNodeValue().equals(extendedFlag))
{
node1 = nodelist1.item(0);
data.addElement(node1.getChildNodes().item(0).getNodeValue());
}
}
}
catch(Exception e){e.printStackTrace();}
return data;
}
public Vector getLayoutidsAndRecordlens(String extendedFlag)
{
int len = 0,length = 0;
Vector data = new Vector();
try
{
nodelist=doc.getElementsByTagName("record");
len=nodelist.getLength();
for(int i=0;i<len;i++)
{
node = nodelist.item(i);
nodelist1 = node.getChildNodes();
node1 = nodelist1.item(1);
if(node1.getChildNodes().item(0).getNodeValue().equals(extendedFlag))
{
String[] res = new String[2];
node1 = nodelist1.item(0);
res[0]=node1.getChildNodes().item(0).getNodeValue();
node1 = nodelist1.item(2);
res[1]=node1.getChildNodes().item(0).getNodeValue();
data.addElement(res);
}
}
}
catch(Exception e){e.printStackTrace();}
return data;
}
public Vector getRecordlens(String extendedFlag)
{
int len = 0,length = 0;
Vector data = new Vector();
try
{
nodelist=doc.getElementsByTagName("record");
len=nodelist.getLength();
for(int i=0;i<len;i++)
{
node = nodelist.item(i);
nodelist1 = node.getChildNodes();
node1 = nodelist1.item(1);
if(node1.getChildNodes().item(0).getNodeValue().equals(extendedFlag))
{
node1 = nodelist1.item(2);
data.addElement(node1.getChildNodes().item(0).getNodeValue());
}
}
}
catch(Exception e){e.printStackTrace();}
return data;
}
public static void main(String args[])
{
if(args.length<1)
{
System.out.println("Give the file name");
}
else
{
Parser parse=new Parser(args[0]);
}
}


}
xml
Hi,
I have already put a question on how to add,delete amd modify the contents of xml from a jsp page. I would like to go for
server side manipulation,using a dom parser but i am unable get exact appraoch can anyone of u send me a sample code reagding
updating and deleting a record in xml from jsp page
reagrds
kalyan
xml
Hi,
I have got a jsp page and a list of records are being displayed in the jsp page and now i have three options insert delete and update. if i click delete it should go to the xml file and delete
that particular record and if i say update it update that particular record in the xml and insert means it should append the record to the xml file without modifying the existing one.please let me know on this aspect about how to approach about
regards
kktata