Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

XML over TCP

Èç¹ûÒªÍêÕûµÄÖ§³ÖXML over TCP£¬Ö»ÓÐÁ½ÖÖ°ì·¨£º
1£¬¼ÓÒ»¸öheaderÈ¥±êÃ÷Êý¾ÝµÄ³¤¶È
2£¬¼ÓÒ»¸ödelimiterÈ¥±êÃ÷Êý¾ÝµÄ½áÊø
ÕâÁ½ÖÖ·½·¨¶¼²»¹»ÓÅÑÅ¡£ÎÒÃDz»ÐèÒªÒ»¸öͨÓõķ½·¨£¬ÎÒÃÇÖ»ÒªÒ»¸ö×îÊʺÏÎÒÃǵķ½·¨¡£
ͨ³££¬ÎÒÃÇÄܹ»×Ô¶¨ÒåÊý¾ÝµÄ¸ñʽ£¬¶øÇÒÎÒÃÇͨ³£Ò»ÌõÏûÏ¢Ö»ÓÐÒ»¸öroot node£¬ÄÇôÎÒÃÇ¿ÉÒÔÊÔÊÔÏÂÃæµÄº¯Êý£º
//return length of the xml message
//return -1 for invalid data
//return 0 for not fully received
int GetXmlLen(string buf, string rootName)
{
string head = "<" + rootName;
if (buf.Length < head.Length)
{
//not fully recved
return 0;
}
if (!buf.StartsWith(head))
{
//invalid
return -1;
}
int idx = buf.IndexOf('>');
if (idx < 0)
{
//not fully recved
return 0;
}
if (buf[idx-1] == '/')
{
//empty root element
return (idx + 1);
}
string tail = "</" + rootName + ">";
idx = buf.IndexOf(tail);
if (idx < 0)
{
//not fully recved
return 0;
}
return (idx + tail.Length);
}
ÒªÇó£ºXMLÏûÏ¢Ö»ÓÐÒ»¸öroot node£¬rootName²»ÊÇÈκÎ×Ó½ÚµãµÄÃû×Ö£¬¶øÇÒÏûÏ¢ÊÇÒÔ"/>"»òÕß"</rootName>"½áβ¡£
Õâ²¢²»ÊǺܿÁ¿ÌµÄÒªÇ󣬴ó¶àÊý»ùÓÚXMLµÄЭÒéʵ¼ÊÉϾÍÊÇÕâÑùµÄ¡£
Èç¹ûÄãµÄXMLЭÒéÂú×ãÉÏÊöÒªÇó£¬ÄÇôµ±ÄãÔÚTCPÉÏ´«ÊäXMLµÄʱºò£¬¾Í¿ÉÒÔÊÔÊÔÎҵĺ¯Êý¡£
PS£ºÕâ¸öʾÀýº¯ÊýÊÇÓÃC#дµÄ£¬ÓÃÆäËûÓïÑÔÒ²ºÜÈÝÒ×ʵÏÖͬÑùµÄ¹¦ÄÜ¡£


Ïà¹ØÎĵµ£º

ÈçºÎ ʹÓà java ²Ù×Ý XML Îļþ


Introduction to XML and XML With Java  
 
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......

dom4j ¶ÁдxmlÎļþ

Ê×ÏÈÎÒÃǸø³öÒ»¶ÎʾÀý³ÌÐò£º
import
 java.io.File;
import
 java.io.FileWriter;
import
 java.util.Iterator;
import
 org.dom4j.Document;
import
 org.dom4j.DocumentHelper;
import
 org.dom4j.Element;
import
 org.dom4j.io.OutputFormat;
import
 org.dom ......

android xml dom½âÊÍ

private
NodeList root(
final
String url , 
final
String str){
      
NodeList root =
null
;
      
try
{
      
InputSource is=
new
InputSource(
new
InputStreamReader(
new
UR ......

spring ÖмÓÔØxmlÅäÖÃÎļþµÄ·½·¨

 
Ò»£ºSpringÖеļ¸ÖÖÈÝÆ÷¶¼Ö§³ÖʹÓÃxml×°Åäbean£¬°üÀ¨£º
    XmlBeanFactory £¬
    ClassPathXmlApplicationContext £¬
    FileSystemXmlApplicationContext £¬
    XmlWebApplicationContext
¼ÓÔØÕâЩÈÝÆ÷µÄÅäÖÃÎļþµÄxmlÓÐһϼ¸ÖÖ³£¼ûµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ