[±¸·Ý]javaÖÐXML½âÎöÀûÆ÷ dom4jµÄʹÓüò½é
ҪʹÓÃdom4j¶ÁдXMLÎĵµ,ÐèÒªÏÈÏÂÔØdom4j°ü,dom4j¹Ù·½ÍøÕ¾ÔÚ http://www.dom4j.org/
Ä¿Ç°×îÐÂdom4j°üÏÂÔصØÖ·: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
½â¿ªºóÓÐÁ½¸ö°ü,½ö²Ù×÷XMLÎĵµµÄ»°°Ñdom4j-1.6.1.jar¼ÓÈ빤³Ì¾Í¿ÉÒÔÁË,Èç¹ûÐèҪʹÓÃXPathµÄ»°»¹ÐèÒª¼ÓÈë°üjaxen-1.1-beta-7.jar.
ÒÔÏÂÊÇÏà¹Ø²Ù×÷:
Ò»¡¢Document¶ÔÏóÏà¹Ø
1.¶ÁÈ¡XMLÎļþ,»ñµÃdocument¶ÔÏó.
SAXReader reader = new SAXReader();
Document document = reader.read(new File("input.xml"));
2.½âÎöXMLÐÎʽµÄÎı¾,µÃµ½document¶ÔÏó.
String text = "<members></members>";
Document document = DocumentHelper.parseText(text);
3.Ö÷¶¯´´½¨document¶ÔÏó.
Document document = DocumentHelper.createDocument();
Element root = document.addElement("members");// ´´½¨¸ù½Úµã
¶þ¡¢½ÚµãÏà¹Ø
1.»ñÈ¡ÎĵµµÄ¸ù½Úµã.
Element rootElm = document.getRootElement();
2.È¡µÃij½ÚµãµÄµ¥¸ö×Ó½Úµã.
Element memberElm=root.element("member");// "member"ÊǽڵãÃû
3.È¡µÃ½ÚµãµÄÎÄ×Ö
String text=memberElm.getText();
Ò²¿ÉÒÔÓÃ:
String text=root.elementText("name");Õâ¸öÊÇÈ¡µÃ¸ù½ÚµãϵÄname×Ö½ÚµãµÄÎÄ×Ö.
4.È¡µÃij½ÚµãÏÂÃûΪ"member"µÄËùÓÐ×ֽڵ㲢½øÐбéÀú.
List nodes = rootElm.elements("member");
for (Iterator it = nodes.iterator(); it.hasNext();) {
Element elm = (Element) it.next();
// do something
}
5.¶Ôij½ÚµãϵÄËùÓÐ×Ó½Úµã½øÐбéÀú.
for(Iterator it=root.elementIterator();it.hasNext();){
Element element = (Element) it.next();
&n
Ïà¹ØÎĵµ£º
·½·¨Ò»£º°´ÕÕXMLµÄ½á¹¹Ò»²½Ò»²½µÄ¹¹½¨XMLÎĵµ.
ͨ¹ý.Net FrameWork SDKÖеÄÃüÃû¿Õ¼ä"System.Xml"Öзâ×°µÄ¸÷ÖÖÀàÀ´ÊµÏÖµÄ
·½·¨¶þ£ºÖ±½Ó¶¨Ó°XMLÎĵµ£¬È»ºó±£´æµ½Îļþ¡£
ͨ¹ý"XmlDocument"ÀàÖеÄ"LoadXml"·½·¨
.aspxǰ̨´úÂë:
<%@ Page Language="C# ......
<%
//header.jsp
out.println("Protocol: " + request.getProtocol() + "<br>");
out.println("Scheme: " + request.getScheme() + "<br>");
out.println("Server Name: " + request.getServerName() + "<br>" );
out.println(&quo ......
StringתCharacterÊý×飬ÓÃCharacterµÄisDigitºÍisLetterº¯ÊýÈ¥Åжϡ£
public static boolean isNumeric(String str) {
for (int i = str.length(); i = 0;) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
public static boolean isNumeric(String str) {
Pattern patt ......
Èí¼þ¼¼ÊõµÄѸÃÍ·¢Õ¹ÈÃJava
ÊÀ½çµÄWeb ¿ò¼Ü
ÁìÓò
·çÆðÔÆÓ¿£¬¸÷Öּܹ¹²ã³ö²»Çµ«ÄãÄÇ?
¡¡¡¡»Øµ½ÁùÄêÇ°µÄ½ñÌì̸ÂÛÕâ¸ö»°Ì⣬ÎÒ»áÍÑ¿Ú¶ø³ö£ºStruts. ÄÇÊÇÒ»¸ö¶ÔStruts¼¸ºõ³ç°ÝµÄʱ´ú£¬¼¸ºõûÈ˶ÔÆäÖÊÒÉ¡£ÄÇʱJava
ÊÀ½çµÄWeb
frameworkÊÀ½çÈç´Ë"µ¥´¿"£¬µ¥´¿µÃÈç´Ë¿ìÀÖ¡£
¡¡¡¡¾µä£¬¿°³Æ¾µä¡£ÌÈÈôÎÒÔÚ´ËÊ ......
×î½üдÔ˼۵Äϵͳ,дµÃºÃÀÛ°¡,²»¹ý²î²»¶à½Ó½üÍê³ÉÁË.µ«±àÂëµÄÎÊÌâÒ»Ö±¶¼ÊÇËƶ®·Ç¶®µÄ.
Ö»ºÃÒ»µãµãÈ¥ËÑË÷javaºÍhtmlµÄ±àÂëÎÊÌâ.ºÃ·³,µ½×îºó,ÎÊÌâÊǽâ¾öÁË,µ«²»ÊÇ×îÍêÕûµÄ´¦Àí·½·¨.Ï£ÍûÒÔºó¿ÉÒÔ´¦ÀíºÃ.
ÔÚÒ»¸östruts2µÄ·µ»ØÌáʾµÄ×Ö·û´®µ½Ò³ÃæÖÐ.ÎÊÌâ¾ÍÊdzöÔÚÕâ×Ö·û´®ÖÐÓÐÍøÒ³µÄ»»Ð ......