hi friends,
my questions are regarding xml with java
1)i want to populate values from data base table to an xml file.how to do it.
2)is there any possiblity to update the xml file whenever the table is updated
3)i want to query that xml file..
for example..i have an xml file in the following structure
<details>
<player>
<pid>0001</pid>
<pname>xxxx</pname>
</player>
<player>
<pid>0001</pid>
<pname>xxxx</pname>
</player>
</details>
so if i give the pid value in the html page it should ind the related name in xml ile and displayed in the html page..
dear friends please help me
karthik
-
java and xml (10 messages)
- Posted by: karthik sa
- Posted on: June 01 2001 11:49 EDT
Threaded Messages (10)
- java and xml by karthik sa on June 01 2001 11:52 EDT
- java and xml by Asad Aziz on June 01 2001 12:50 EDT
- java and xml by Scott Hernandez on June 01 2001 20:17 EDT
-
java and xml by karthik sa on June 04 2001 07:57 EDT
-
java and xml by Wojciech Ozimek on June 04 2001 01:09 EDT
-
java and xml by karthik sa on June 06 2001 06:27 EDT
-
java and xml by Wojciech Ozimek on June 07 2001 03:40 EDT
-
java and xml by karthik sa on June 07 2001 01:22 EDT
-
java and xml by Wojciech Ozimek on June 08 2001 06:03 EDT
- java and xml by karthik sa on June 08 2001 03:42 EDT
-
java and xml by Wojciech Ozimek on June 08 2001 06:03 EDT
-
java and xml by karthik sa on June 07 2001 01:22 EDT
-
java and xml by Wojciech Ozimek on June 07 2001 03:40 EDT
-
java and xml by karthik sa on June 06 2001 06:27 EDT
-
java and xml by Wojciech Ozimek on June 04 2001 01:09 EDT
-
java and xml by karthik sa on June 04 2001 07:57 EDT
-
java and xml[ Go to top ]
- Posted by: karthik sa
- Posted on: June 01 2001 11:52 EDT
- in response to karthik sa
sorry small mistake in that question..read it now
hi friends,
my questions are regarding xml with java
1)i want to populate values from data base table to an xml file.how to do it.
2)is there any possiblity to update the xml file whenever the table is updated
3)i want to query that xml file.. for example..i have an xml file in the following structure
<details>
<player>
<pid>0001</pid>
<pname>xxxx</pname>
</player>
<player>
<pid>0002</pid>
<pname>yyyy</pname>
</player>
</details>
so if i give the pid value in the html page it should ind the related name in xml ile and displayed in the html page..
dear friends please help me
karthik -
java and xml[ Go to top ]
- Posted by: Asad Aziz
- Posted on: June 01 2001 12:50 EDT
- in response to karthik sa
Hi
This is one of making a XML file from the data in the databse.
FileOutputStream outStrem = new FileOutputStream("Player.xml");
PrintStream p = new PrintStream(outStream);
String xmlreader="<?xml version='1.0' ?><details>";
while(rs.next())
{
xmlreader += "<pid>"+ rs.getInt("pid") +"</pid>":
xmlreader "<player><pname>"+ .getString"pname")+ "</pname>
</player>";
}
xmlreader += "</details>";
p.print(xmlreader);
In order to retrive data from xml file or search a xml file u need to impelement java SAX or org.xml.sax
Hope this works
Bye
Asad
-
java and xml[ Go to top ]
- Posted by: Scott Hernandez
- Posted on: June 01 2001 20:17 EDT
- in response to karthik sa
XPath provides a simple set of query (selection) expressions.
In xpath you could select the node(s) you want by saying:
//player[pid='0001']
This will select any player node (in the current tree) that has a pid child element with the text '0001'.
dom4j (www.dom4j.org) support xpath.
"Node.selectNodes(String xpathExpression)
selectNodes evaluates an XPath expression and returns the result as a List of Node instances or String instances depending on the XPath expression."
Hope this helps...
Later,
skot -
java and xml[ Go to top ]
- Posted by: karthik sa
- Posted on: June 04 2001 07:57 EDT
- in response to Scott Hernandez
hello guys,
thx for your help..let me try it..can u please tell me some useful sites for that(regarding xpath etc)..
thanks again
karthik -
java and xml[ Go to top ]
- Posted by: Wojciech Ozimek
- Posted on: June 04 2001 13:09 EDT
- in response to karthik sa
Try this one:
http://www.zvon.org/
There's a lot of tutorials and references in it.
Direct link to XPath tutorial:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
XPath is closely connected with XSLT, so any documents covering XSL are likely to include XPath examples (try XSL links at Zvon.org)
Regards
Wojtek
-
java and xml[ Go to top ]
- Posted by: karthik sa
- Posted on: June 06 2001 06:27 EDT
- in response to Wojciech Ozimek
Hi friend,
Thanks for ur reply..i saw the site u have given..it was good..but im not able to find a good xpath tutorial with java..can anyone send me an example files or can anyone tell me some sites for java and xpath
thank you -
java and xml[ Go to top ]
- Posted by: Wojciech Ozimek
- Posted on: June 07 2001 03:40 EDT
- in response to karthik sa
Using XPath with Java requires XSL translator package. You can get one from xml.apache.org (it's called Xalan). There are some examples attached to it. Using XPath in Java is starightforward. All you must write is XSL transformation. Check Xalan examples.
Regards
Wojtek -
java and xml[ Go to top ]
- Posted by: karthik sa
- Posted on: June 07 2001 13:22 EDT
- in response to Wojciech Ozimek
hi wojtek,
thax for your help again..i havent tried xalan..before that i want to query xml thru client side itself using xsl and (or) java script..here is a file i found in net..here they compared artist name and display correspondin details..is there anyway to pass that dynamicallyusing javascript or something else without using java..ie..i want to pass that artist value from html..how to i get the value from html page and substitue in that condition...
the xsl file is
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="CATALOG/CD[ARTIST='Bob Dylan']"> //here i want to pass the values dynamically
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
hope u help me again
karthik
-
java and xml[ Go to top ]
- Posted by: Wojciech Ozimek
- Posted on: June 08 2001 06:03 EDT
- in response to karthik sa
The only way you can do it is to use Internet Explorer XSL translation capabilities (I don't know if Netscape has it's equivalent). IE reads XML files (to translate it with suitable XSL, you should include the following line into the XML):
<?xml-stylesheet type="text/xsl" href="myXSL.xsl"?>
This should work fine, but I suggest to use server-side translations. They're browser independent. -
java and xml[ Go to top ]
- Posted by: karthik sa
- Posted on: June 08 2001 15:42 EDT
- in response to Wojciech Ozimek
hi wojtek,
im aware of using xml with xsl..but i wanna know how to pass that values(i specified abt it in my last question)
dynamically to xsl..
if u know pls help