Python论坛  - 讨论区

标题:[python-chinese] 通过http传递xml节点元素的疑惑

2007年03月02日 星期五 15:18

hch huangchonggnu在gmail.com
星期五 三月 2 15:18:31 HKT 2007

´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ

...
......
...

clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£

ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬Í¨¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/7d114c81/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 15:29

bird devdoer devdoer在gmail.com
星期五 三月 2 15:29:14 HKT 2007

不明白难在哪里,不就是一个字符串字节流么,直接传不就可以了,当然要注意相邻字符串的边界,可以预定义一个简单的包格式
strcut{
int size;
string xml;
}

在07-3-2,hch <huangchonggnu at gmail.com> 写道:
>
> 大家好,小弟有一个问题,是这样的,
> client与web server每隔1分钟,要同步一xml文件。xml格式大概是这样的
> 
> ...
> ......
> ...
> 
> client的id条目在不断增加,考虑到这个文件会达到上百兆,重传一次很耗时。所以只把新增的id条目取出,添加到服务器端的xml里。
>
> 我的想法是,把新增的id条目组成一列表,把这个列表传递到server端,通过xml.dom.minidom里的.appendChild更新xml文件
> 。可是这个节点对象的列表该怎么传过去呢,是不是该用pickle(对对象序列化很不熟),哪位能给我指点一下方向,谢谢^^
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
devdoer
devdoer at gmail.com
http://devdoer.blog.sohu.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/05be81bf/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 15:48

hch huangchonggnu在gmail.com
星期五 三月 2 15:48:24 HKT 2007

ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
Dom = xml.dom.minidom.parse(f)
idNodeList = Dom.getElementsByTagName('id')
idList = idNodeList[addedStartLocation:]
param = "ID_LIST=%s" % idList
urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)

server¶Ë£º
Dom = xml.dom.minidom.parse(f)
firstChildNode = Dom.firstChild
for id in ID_LIST:
    firstChildNode.appendChild(id)
fd = open(f, 'w')
Dom.writexml(fd, encoding='utf-8')
fd.close()

±¨´íÊÇÕâÑùµÄ
  ...... line 33, in receive
    firstChildNode.appendChild(id)

  File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117,
in appendChild
    if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:

AttributeError: 'str' object has no attribute 'nodeType'
ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ


ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
>
> ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> strcut{
> int size;
> string xml;
> }
>
> ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> >
> > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > 
> > ...
> > ......
> > ...
> > 
> > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> >
> > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> devdoer
> devdoer在gmail.com
> http://devdoer.blog.sohu.com/
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/fa66f7ef/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 16:15

=?GB2312?B?hWSEXoVk?= wanliyou在gmail.com
星期五 三月 2 16:15:38 HKT 2007

传的是string,又不是element,老老实实把string都发过去,再load成可以dom操作的xml对象,最后append

On 3/2/07, hch <huangchonggnu at gmail.com> wrote:
>
> 我直接传列表,代码是这样的,client端
> Dom = xml.dom.minidom.parse(f)
> idNodeList = Dom.getElementsByTagName('id')
> idList = idNodeList[addedStartLocation:]
> param = "ID_LIST=%s" % idList
> urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)
>
> server端:
> Dom = xml.dom.minidom.parse(f)
> firstChildNode = Dom.firstChild
> for id in ID_LIST:
>     firstChildNode.appendChild(id)
> fd = open(f, 'w')
> Dom.writexml(fd, encoding='utf-8')
> fd.close()
>
> 报错是这样的
>   ...... line 33, in receive
>     firstChildNode.appendChild(id)
>
>   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line
> 117, in appendChild
>     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
>
> AttributeError: 'str' object has no attribute 'nodeType'
> 我觉得和对象序列化有关系呀
>
>
> 在07-3-2,bird devdoer <devdoer at gmail.com> 写道:
> >
> > 不明白难在哪里,不就是一个字符串字节流么,直接传不就可以了,当然要注意相邻字符串的边界,可以预定义一个简单的包格式
> > strcut{
> > int size;
> > string xml;
> > }
> >
> > 在07-3-2,hch < huangchonggnu at gmail.com> 写道:
> > >
> > > 大家好,小弟有一个问题,是这样的,
> > > client与web server每隔1分钟,要同步一xml文件。xml格式大概是这样的
> > > 
> > > ...
> > > ......
> > > ...
> > > 
> > > client的id条目在不断增加,考虑到这个文件会达到上百兆,重传一次很耗时。所以只把新增的id条目取出,添加到服务器端的xml里。
> > >
> > > 我的想法是,把新增的id条目组成一列表,把这个列表传递到server端,
> > > 通过xml.dom.minidom里的.appendChild更新xml文件
> > > 。可是这个节点对象的列表该怎么传过去呢,是不是该用pickle(对对象序列化很不熟),哪位能给我指点一下方向,谢谢^^
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > devdoer
> > devdoer at gmail.com
> > http://devdoer.blog.sohu.com/
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
------======Nerazzurri======------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/71bed0bd/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 16:32

hch huangchonggnu在gmail.com
星期五 三月 2 16:32:05 HKT 2007

ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡

ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
>
> ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
>
> On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> >
> > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > Dom = xml.dom.minidom.parse(f)
> > idNodeList = Dom.getElementsByTagName ('id')
> > idList = idNodeList[addedStartLocation:]
> > param = "ID_LIST=%s" % idList
> > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)
> >
> > server¶Ë£º
> > Dom = xml.dom.minidom.parse(f)
> > firstChildNode = Dom.firstChild
> > for id in ID_LIST:
> >     firstChildNode.appendChild(id)
> > fd = open(f, 'w')
> > Dom.writexml(fd, encoding='utf-8')
> > fd.close()
> >
> > ±¨´íÊÇÕâÑùµÄ
> >   ...... line 33, in receive
> >     firstChildNode.appendChild(id)
> >
> >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line
> > 117, in appendChild
> >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> >
> > AttributeError: 'str' object has no attribute 'nodeType'
> > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> >
> >
> > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > >
> > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > strcut{
> > > int size;
> > > string xml;
> > > }
> > >
> > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > >
> > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > 
> > > > ...
> > > > ......
> > > > ...
> > > > 
> > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > >
> > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > devdoer
> > > devdoer在gmail.com
> > > http://devdoer.blog.sohu.com/
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> ------======Nerazzurri======------
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/2f1bb27f/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 16:54

玄利磊 kency在zctt.com.cn
星期五 三月 2 16:54:06 HKT 2007

Òª×öÒ»¸öPythonµÄ½²×ù

Ö÷ÒªÕë¶ÔÓжàÄ꿪·¢¾­ÑéµÄ£Ã£«£«µÄ³ÌÐòÔ±

Ö÷ÒªÔõô½²±È½ÏºÃ¡¡½²Ð©Ê²Ã´±È½ÏºÃ
Ï£ÍûÓо­ÑéµÄ¸øЩ½¨Òé

лл£¡£¡




ÐþÀûÀÚ
2007-03-02
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/b3e7e31e/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 17:58

bird devdoer devdoer在gmail.com
星期五 三月 2 17:58:29 HKT 2007

Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
°´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
xml½âÎöÆ÷½âÎöÒ»ÏÂ

ÔÚ07-3-2£¬hch <huangchonggnu at gmail.com> дµÀ£º
>
> ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
>
> ÔÚ07-3-2£¬…d„^…d <wanliyou at gmail.com> дµÀ£º
> >
> > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> >
> > On 3/2/07, hch <huangchonggnu at gmail.com > wrote:
> > >
> > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > Dom = xml.dom.minidom.parse(f)
> > > idNodeList = Dom.getElementsByTagName ('id')
> > > idList = idNodeList[addedStartLocation:]
> > > param = "ID_LIST=%s" % idList
> > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)
> > >
> > > server¶Ë£º
> > > Dom = xml.dom.minidom.parse(f)
> > > firstChildNode = Dom.firstChild
> > > for id in ID_LIST:
> > >     firstChildNode.appendChild(id)
> > > fd = open(f, 'w')
> > > Dom.writexml(fd, encoding='utf-8')
> > > fd.close()
> > >
> > > ±¨´íÊÇÕâÑùµÄ
> > >   ...... line 33, in receive
> > >     firstChildNode.appendChild(id)
> > >
> > >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py",
> > > line 117, in appendChild
> > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > >
> > > AttributeError: 'str' object has no attribute 'nodeType'
> > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > >
> > >
> > > ÔÚ07-3-2£¬bird devdoer <devdoer at gmail.com> дµÀ£º
> > > >
> > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > strcut{
> > > > int size;
> > > > string xml;
> > > > }
> > > >
> > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > >
> > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > 
> > > > > ...
> > > > > ......
> > > > > ...
> > > > > 
> > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > >
> > > > >
> > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > devdoer
> > > > devdoer at gmail.com
> > > > http://devdoer.blog.sohu.com/
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > ------======Nerazzurri======------
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
devdoer
devdoer at gmail.com
http://devdoer.blog.sohu.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/5160d7fd/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 18:16

hch huangchonggnu在gmail.com
星期五 三月 2 18:16:06 HKT 2007

°ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
"×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ

ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
>
> Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> xml½âÎöÆ÷½âÎöÒ»ÏÂ
>
> ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> >
> > ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> >
> > ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
> > >
> > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > >
> > > On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> > > >
> > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > Dom = xml.dom.minidom.parse(f)
> > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > idList = idNodeList[addedStartLocation:]
> > > > param = "ID_LIST=%s" % idList
> > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)
> > > >
> > > > server¶Ë£º
> > > > Dom = xml.dom.minidom.parse(f)
> > > > firstChildNode = Dom.firstChild
> > > > for id in ID_LIST:
> > > >     firstChildNode.appendChild(id)
> > > > fd = open(f, 'w')
> > > > Dom.writexml(fd, encoding='utf-8')
> > > > fd.close()
> > > >
> > > > ±¨´íÊÇÕâÑùµÄ
> > > >   ...... line 33, in receive
> > > >     firstChildNode.appendChild(id)
> > > >
> > > >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py",
> > > > line 117, in appendChild
> > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > >
> > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > >
> > > >
> > > > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > > > >
> > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > strcut{
> > > > > int size;
> > > > > string xml;
> > > > > }
> > > > >
> > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > >
> > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > 
> > > > > > ...
> > > > > > ......
> > > > > > ...
> > > > > > 
> > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > >
> > > > > >
> > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese在lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > devdoer
> > > > > devdoer在gmail.com
> > > > > http://devdoer.blog.sohu.com/
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > ------======Nerazzurri======------
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> devdoer
> devdoer在gmail.com
> http://devdoer.blog.sohu.com/
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/6559d4b9/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月02日 星期五 19:44

bird devdoer devdoer在gmail.com
星期五 三月 2 19:44:46 HKT 2007

Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á


"Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬

ÔÚ07-3-2£¬hch <huangchonggnu at gmail.com> дµÀ£º
>
> °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
>
> ÔÚ07-3-2£¬bird devdoer < devdoer at gmail.com> дµÀ£º
> >
> > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> >
> > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > >
> > > ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > >
> > > ÔÚ07-3-2£¬…d„^…d <wanliyou at gmail.com> дµÀ£º
> > > >
> > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > >
> > > > On 3/2/07, hch <huangchonggnu at gmail.com > wrote:
> > > > >
> > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > Dom = xml.dom.minidom.parse(f)
> > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > idList = idNodeList[addedStartLocation:]
> > > > > param = "ID_LIST=%s" % idList
> > > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp , param)
> > > > >
> > > > >
> > > > > server¶Ë£º
> > > > > Dom = xml.dom.minidom.parse(f)
> > > > > firstChildNode = Dom.firstChild
> > > > > for id in ID_LIST:
> > > > >     firstChildNode.appendChild(id)
> > > > > fd = open(f, 'w')
> > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > fd.close()
> > > > >
> > > > > ±¨´íÊÇÕâÑùµÄ
> > > > >   ...... line 33, in receive
> > > > >     firstChildNode.appendChild(id)
> > > > >
> > > > >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py",
> > > > > line 117, in appendChild
> > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > >
> > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > >
> > > > >
> > > > > ÔÚ07-3-2£¬bird devdoer <devdoer at gmail.com> дµÀ£º
> > > > > >
> > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > strcut{
> > > > > > int size;
> > > > > > string xml;
> > > > > > }
> > > > > >
> > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > >
> > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > 
> > > > > > > ...
> > > > > > > ......
> > > > > > > ...
> > > > > > > 
> > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > >
> > > > > > >
> > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > devdoer
> > > > > > devdoer at gmail.com
> > > > > > http://devdoer.blog.sohu.com/
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese at lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > ------======Nerazzurri======------
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > devdoer
> > devdoer at gmail.com
> > http://devdoer.blog.sohu.com/
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
devdoer
devdoer at gmail.com
http://devdoer.blog.sohu.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070302/70a4fbba/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 09:42

hch huangchonggnu在gmail.com
星期一 三月 5 09:42:49 HKT 2007

²éÁËxml.dom.minidomµÄapi£¬
»¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
>
> Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
>
>
> "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
>
> ÔÚ07-3-2£¬ hch <huangchonggnu在gmail.com> дµÀ£º
> >
> > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> >
> > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > >
> > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > >
> > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > >
> > > > ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > >
> > > > ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
> > > > >
> > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > >
> > > > > On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> > > > > >
> > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > param = "ID_LIST=%s" % idList
> > > > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp ,
> > > > > > param)
> > > > > >
> > > > > > server¶Ë£º
> > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > firstChildNode = Dom.firstChild
> > > > > > for id in ID_LIST:
> > > > > >     firstChildNode.appendChild(id)
> > > > > > fd = open(f, 'w')
> > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > fd.close()
> > > > > >
> > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > >   ...... line 33, in receive
> > > > > >     firstChildNode.appendChild(id)
> > > > > >
> > > > > >   File
> > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > appendChild
> > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > >
> > > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > >
> > > > > >
> > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > > > > > >
> > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > strcut{
> > > > > > > int size;
> > > > > > > string xml;
> > > > > > > }
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > 
> > > > > > > > ...
> > > > > > > > ......
> > > > > > > > ...
> > > > > > > > 
> > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > >
> > > > > > > >
> > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > devdoer
> > > > > > > devdoer在gmail.com
> > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese在lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > ------======Nerazzurri======------
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > devdoer
> > > devdoer在gmail.com
> > > http://devdoer.blog.sohu.com/
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> devdoer
> devdoer在gmail.com
> http://devdoer.blog.sohu.com/
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/2d90ac2f/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 09:57

=?GB2312?B?hWSEXoVk?= wanliyou在gmail.com
星期一 三月 5 09:57:51 HKT 2007

ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©

On 3/5/07, hch <huangchonggnu at gmail.com> wrote:
>
>
> ²éÁËxml.dom.minidomµÄapi£¬
> »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> ÔÚ07-3-2£¬bird devdoer < devdoer at gmail.com> дµÀ£º
> >
> > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> >
> >
> > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> >
> > ÔÚ07-3-2£¬ hch <huangchonggnu at gmail.com> дµÀ£º
> > >
> > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > >
> > > ÔÚ07-3-2£¬ bird devdoer < devdoer at gmail.com> дµÀ£º
> > > >
> > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > >
> > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > >
> > > > > ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > >
> > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou at gmail.com> дµÀ£º
> > > > > >
> > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > >
> > > > > >
> > > > > > On 3/2/07, hch <huangchonggnu at gmail.com > wrote:
> > > > > > >
> > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp ,
> > > > > > > param)
> > > > > > >
> > > > > > > server¶Ë£º
> > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > firstChildNode = Dom.firstChild
> > > > > > > for id in ID_LIST:
> > > > > > >     firstChildNode.appendChild(id)
> > > > > > > fd = open(f, 'w')
> > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > fd.close()
> > > > > > >
> > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > >   ...... line 33, in receive
> > > > > > >     firstChildNode.appendChild(id)
> > > > > > >
> > > > > > >   File
> > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > appendChild
> > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > >
> > > > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > >
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer at gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > strcut{
> > > > > > > > int size;
> > > > > > > > string xml;
> > > > > > > > }
> > > > > > > >
> > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > > > >
> > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > 
> > > > > > > > > ...
> > > > > > > > > ......
> > > > > > > > > ...
> > > > > > > > > 
> > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > devdoer
> > > > > > > > devdoer at gmail.com
> > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > ------======Nerazzurri======------
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese at lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > devdoer
> > > > devdoer at gmail.com
> > > > http://devdoer.blog.sohu.com/
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > devdoer
> > devdoer at gmail.com
> > http://devdoer.blog.sohu.com/
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
------======Nerazzurri======------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/ca5a0111/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 10:38

hch huangchonggnu在gmail.com
星期一 三月 5 10:38:52 HKT 2007

ÏÖÔÚÄܰѽڵãͨ¹ýtoxml()·½·¨×Ö·û´®»¯ÁË£¬µ«ÊÇ´«µ½server¶Ëʱ£¬ÓÖÈçºÎ°ÑËüÃÇ»¹Ô­³É½Úµã¶ÔÏóµÄÁбíÄØ£¿


...... line 33, in receive
    firstChildNode.appendChild(id)

  File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117,
in appendChild
    if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:

AttributeError: 'str' object has no attribute 'nodeType'

»¹ÊÇÕâ¸ö±¨´í¡£ºÃÏñ¾ÍÊÇÒòΪ´«µÝ¹ýÈ¥µÄÊÇid×Ö·û´®¶ÔÏó£¬ËùÒÔappendChild(id),²»¹ÜÓÃÄÄ

ÔÚ07-3-5£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
>
> ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©
>
> On 3/5/07, hch <huangchonggnu在gmail.com> wrote:
> >
> >
> > ²éÁËxml.dom.minidomµÄapi£¬
> > »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > >
> > > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> > >
> > >
> > > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> > >
> > > ÔÚ07-3-2£¬ hch <huangchonggnu在gmail.com> дµÀ£º
> > > >
> > > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > > >
> > > > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > > > >
> > > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > > >
> > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > >
> > > > > > ÄÇô°Ñelement ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > > >
> > > > > >
> > > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
> > > > > > >
> > > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > > >
> > > > > > >
> > > > > > > On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> > > > > > > >
> > > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp ,
> > > > > > > > param)
> > > > > > > >
> > > > > > > > server¶Ë£º
> > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > firstChildNode = Dom.firstChild
> > > > > > > > for id in ID_LIST:
> > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > fd = open(f, 'w')
> > > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > > fd.close()
> > > > > > > >
> > > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > > >   ...... line 33, in receive
> > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > >
> > > > > > > >   File
> > > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > > appendChild
> > > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > > >
> > > > > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > > >
> > > > > > > >
> > > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > > > > > > > >
> > > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > > strcut{
> > > > > > > > > int size;
> > > > > > > > > string xml;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > > > >
> > > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > > 
> > > > > > > > > > ...
> > > > > > > > > > ......
> > > > > > > > > > ...
> > > > > > > > > > 
> > > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > > >
> > > > > > > > > > _______________________________________________
> > > > > > > > > > python-chinese
> > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Detail Info:
> > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > devdoer
> > > > > > > > > devdoer在gmail.com
> > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > ------======Nerazzurri======------
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese在lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > devdoer
> > > > > devdoer在gmail.com
> > > > > http://devdoer.blog.sohu.com/
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > devdoer
> > > devdoer在gmail.com
> > > http://devdoer.blog.sohu.com/
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> ------======Nerazzurri======------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/8a9327d5/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 14:25

=?GB2312?B?hWSEXoVk?= wanliyou在gmail.com
星期一 三月 5 14:25:28 HKT 2007

XML={};
XML.newDocument = function(rootTagName, namespaceURL) {
    if (!rootTagName) rootTagName = "";
    if (!namespaceURL) namespaceURL = "";

    if (document.implementation && document.implementation.createDocument) {
        // W3C standard way
        return document.implementation.createDocument(namespaceURL,
rootTagName, null);
    }
    else { // IE way
        var doc = new ActiveXObject(" MSXML2.DOMDocument");
        if (rootTagName) {
            var prefix = "";
            var tagname = rootTagName;
            var p = rootTagName.indexOf(':');
            if (p != -1) {
                prefix = rootTagName.substring(0, p);
                tagname = rootTagName.substring(p+1);
            }
            if (namespaceURL) {
                if (!prefix) prefix = "a0"; // What Firefox uses
            }
            else prefix = "";
            var text = "<" + (prefix?(prefix+":"):"") +  tagname +
                (namespaceURL
                 ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
                 :"") +
                " />";
            // And parse that text into the empty document
            doc.loadXML(text);
        }
        return doc;
    }
};

ÕâÊÇjavascriptн¨Ò»¸öXML
doc¶ÔÏóºÍµ¼Èëtext/stringµÄ¹ý³Ì¡£Èç¹ûÊǸöAjaxÓ¦Óã¬Õâ¸ö¿ÉÒÔÓÃXMLHttpRequestÀ´Í¬²½½Úµã¡£

PythonÀïµ¥´¿Îı¾´¦Àí from xml.dom.minidom import parse, parseString

Ï£Íû¶ÔÄãÓÐÓÃ


On 3/5/07, hch <huangchonggnu at gmail.com> wrote:
>
> ÏÖÔÚÄܰѽڵãͨ¹ýtoxml()·½·¨×Ö·û´®»¯ÁË£¬µ«ÊÇ´«µ½server¶Ëʱ£¬ÓÖÈçºÎ°ÑËüÃÇ»¹Ô­³É½Úµã¶ÔÏóµÄÁбíÄØ£¿
>
>
> ...... line 33, in receive
>     firstChildNode.appendChild(id)
>
>   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line
> 117, in appendChild
>     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
>
> AttributeError: 'str' object has no attribute 'nodeType'
>
> »¹ÊÇÕâ¸ö±¨´í¡£ºÃÏñ¾ÍÊÇÒòΪ´«µÝ¹ýÈ¥µÄÊÇid×Ö·û´®¶ÔÏó£¬ËùÒÔappendChild(id),²»¹ÜÓÃÄÄ
>
> ÔÚ07-3-5£¬ …d„^…d <wanliyou at gmail.com> дµÀ£º
> >
> > ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©
> >
> > On 3/5/07, hch < huangchonggnu at gmail.com> wrote:
> > >
> > >
> > > ²éÁËxml.dom.minidomµÄapi£¬
> > > »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> > > ÔÚ07-3-2£¬ bird devdoer < devdoer at gmail.com> дµÀ£º
> > > >
> > > > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> > > >
> > > >
> > > > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> > > >
> > > > ÔÚ07-3-2£¬ hch <huangchonggnu at gmail.com> дµÀ£º
> > > > >
> > > > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > > > >
> > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer at gmail.com> дµÀ£º
> > > > > >
> > > > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > > > >
> > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > >
> > > > > > > ÄÇô°Ñelement
> > > > > > > ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou at gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > > > >
> > > > > > > >
> > > > > > > > On 3/2/07, hch <huangchonggnu at gmail.com > wrote:
> > > > > > > > >
> > > > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > > > urllib2.urlopen("http://%s/receive.py/receive" % ServerIp
> > > > > > > > > , param)
> > > > > > > > >
> > > > > > > > > server¶Ë£º
> > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > firstChildNode = Dom.firstChild
> > > > > > > > > for id in ID_LIST:
> > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > fd = open(f, 'w')
> > > > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > > > fd.close()
> > > > > > > > >
> > > > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > > > >   ...... line 33, in receive
> > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > >
> > > > > > > > >   File
> > > > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > > > appendChild
> > > > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > > > >
> > > > > > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer at gmail.com> дµÀ£º
> > > > > > > > > >
> > > > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > > >
> > > > > > > > > > strcut{
> > > > > > > > > > int size;
> > > > > > > > > > string xml;
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > > > > > >
> > > > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > > > 
> > > > > > > > > > > ...
> > > > > > > > > > > ......
> > > > > > > > > > > ...
> > > > > > > > > > > 
> > > > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > > > >
> > > > > > > > > > > _______________________________________________
> > > > > > > > > > > python-chinese
> > > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > Detail Info:
> > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > devdoer
> > > > > > > > > > devdoer at gmail.com
> > > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > > > _______________________________________________
> > > > > > > > > > python-chinese
> > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > Detail Info:
> > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > ------======Nerazzurri======------
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > devdoer
> > > > > > devdoer at gmail.com
> > > > > > http://devdoer.blog.sohu.com/
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese at lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > devdoer
> > > > devdoer at gmail.com
> > > > http://devdoer.blog.sohu.com/
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > ------======Nerazzurri======------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to   python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
------======Nerazzurri======------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/3689d21f/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 14:45

麦田守望者 qcxhome在gmail.com
星期一 三月 5 14:45:10 HKT 2007

On 3/2/07, hch <huangchonggnu at gmail.com> wrote:
> 大家好,小弟有一个问题,是这样的,
> client与web server每隔1分钟,要同步一xml文件。xml格式大概是这样的
> 
> ...
> ......
> ...
> 
> client的id条目在不断增加,考虑到这个文件会达到上百兆,重传一次很耗时。所以只把新增的id条目取出,添加到服务器端的xml里。
>
> 我的想法是,把新增的id条目组成一列表,把这个列表传递到server端,通过xml.dom.minidom里的.appendChild更新xml文件。可是这个节点对象的列表该怎么传过去呢,是不是该用pickle(对对象序列化很不熟),哪位能给我指点一下方向,谢谢^^
>

使用栈或者递归,遍历dom树,转换成字符串再发送出去。

-- 
GoogleTalk: qcxhome at gmail.com
MSN: qcxhome at hotmail.com
My Space: tkdchen.spaces.live.com
BOINC: boinc.berkeley.edu
中国分布式计算总站: www.equn.com

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 15:04

hch huangchonggnu在gmail.com
星期一 三月 5 15:04:38 HKT 2007

ºÇºÇ£¬Ð»Ð»°¡£¬¿ÉϧÎÒÕ⻹Óò»µ½Ç°Ì¨µÄjavascript¼¼Êõ¡£
»¹ÓÐÒ»¸ö£¬ÎÒ¸Õ·¢ÏÖ£¬ÓÃminidom ½âÎö±È½Ï´óµÄxmlÎļþ£¬ÏñÎÒÕâ¸ö10mÒÔÉϵģ¬¾ÍºÜ²»ºÏÊÊÁË¡£

ÔÚ07-3-5£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
>
> XML={};
> XML.newDocument = function(rootTagName, namespaceURL) {
>     if (!rootTagName) rootTagName = "";
>     if (!namespaceURL) namespaceURL = "";
>
>     if (document.implementation && document.implementation.createDocument)
> {
>         // W3C standard way
>         return document.implementation.createDocument(namespaceURL,
> rootTagName, null);
>     }
>     else { // IE way
>         var doc = new ActiveXObject(" MSXML2.DOMDocument");
>         if (rootTagName) {
>             var prefix = "";
>             var tagname = rootTagName;
>             var p = rootTagName.indexOf(':');
>             if (p != -1) {
>                 prefix = rootTagName.substring(0, p);
>                 tagname = rootTagName.substring(p+1);
>             }
>             if (namespaceURL) {
>                 if (!prefix) prefix = "a0"; // What Firefox uses
>             }
>             else prefix = "";
>             var text = "<" + (prefix?(prefix+":"):"") +  tagname +
>                 (namespaceURL
>                  ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
>                  :"") +
>                 "/>";
>             // And parse that text into the empty document
>             doc.loadXML(text);
>         }
>         return doc;
>     }
> };
>
> ÕâÊÇjavascriptн¨Ò»¸öXML
> doc¶ÔÏóºÍµ¼Èëtext/stringµÄ¹ý³Ì¡£Èç¹ûÊǸöAjaxÓ¦Óã¬Õâ¸ö¿ÉÒÔÓÃXMLHttpRequestÀ´Í¬²½½Úµã¡£
>
> PythonÀïµ¥´¿Îı¾´¦Àí from xml.dom.minidom import parse, parseString
>
> Ï£Íû¶ÔÄãÓÐÓÃ
>
>
> On 3/5/07, hch <huangchonggnu在gmail.com> wrote:
> >
> > ÏÖÔÚÄܰѽڵãͨ¹ýtoxml()·½·¨×Ö·û´®»¯ÁË£¬µ«ÊÇ´«µ½server¶Ëʱ£¬ÓÖÈçºÎ°ÑËüÃÇ»¹Ô­³É½Úµã¶ÔÏóµÄÁбíÄØ£¿
> >
> >
> > ...... line 33, in receive
> >     firstChildNode.appendChild(id)
> >
> >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line
> > 117, in appendChild
> >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> >
> > AttributeError: 'str' object has no attribute 'nodeType'
> >
> > »¹ÊÇÕâ¸ö±¨´í¡£ºÃÏñ¾ÍÊÇÒòΪ´«µÝ¹ýÈ¥µÄÊÇid×Ö·û´®¶ÔÏó£¬ËùÒÔappendChild(id),²»¹ÜÓÃÄÄ
> >
> > ÔÚ07-3-5£¬ …d„^…d <wanliyou在gmail.com> дµÀ£º
> > >
> > > ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©
> > >
> > > On 3/5/07, hch < huangchonggnu在gmail.com> wrote:
> > > >
> > > >
> > > > ²éÁËxml.dom.minidomµÄapi£¬
> > > > »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> > > > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > > > >
> > > > > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> > > > >
> > > > >
> > > > > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> > > > >
> > > > > ÔÚ07-3-2£¬ hch <huangchonggnu在gmail.com> дµÀ£º
> > > > > >
> > > > > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > > > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > > > > >
> > > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > > > > > >
> > > > > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > ÄÇô°Ñelement
> > > > > > > > ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > > > > >
> > > > > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
> > > > > > > > >
> > > > > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> > > > > > > > > >
> > > > > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > > > > urllib2.urlopen("http://%s/receive.py/receive" %
> > > > > > > > > > ServerIp , param)
> > > > > > > > > >
> > > > > > > > > > server¶Ë£º
> > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > firstChildNode = Dom.firstChild
> > > > > > > > > > for id in ID_LIST:
> > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > > fd = open(f, 'w')
> > > > > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > > > > fd.close()
> > > > > > > > > >
> > > > > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > > > > >   ...... line 33, in receive
> > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > >
> > > > > > > > > >   File
> > > > > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > > > > appendChild
> > > > > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > > > > >
> > > > > > > > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > > > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > > > > > > > > > >
> > > > > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > > > >
> > > > > > > > > > > strcut{
> > > > > > > > > > > int size;
> > > > > > > > > > > string xml;
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > > > > > >
> > > > > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > > > > 
> > > > > > > > > > > > ...
> > > > > > > > > > > > ......
> > > > > > > > > > > > ...
> > > > > > > > > > > > 
> > > > > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > > > > >
> > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > python-chinese
> > > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > devdoer
> > > > > > > > > > > devdoer在gmail.com
> > > > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > > > > _______________________________________________
> > > > > > > > > > > python-chinese
> > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > Detail Info:
> > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _______________________________________________
> > > > > > > > > > python-chinese
> > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Detail Info:
> > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > ------======Nerazzurri======------
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > devdoer
> > > > > > > devdoer在gmail.com
> > > > > > > http://devdoer.blog.sohu.com/
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese在lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > devdoer
> > > > > devdoer在gmail.com
> > > > > http://devdoer.blog.sohu.com/
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > ------======Nerazzurri======------
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> ------======Nerazzurri======------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/af761ead/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 15:12

=?GB2312?B?hWSEXoVk?= wanliyou在gmail.com
星期一 三月 5 15:12:38 HKT 2007

from xml.dom.minidom import parse, parseString
²»ÐÐô£¿
ʲô¶«Î÷¸É¸ö10MµÄÎı¾¶¼²»»áÌ«¿ì¡£¡£¡£

On 3/5/07, hch <huangchonggnu at gmail.com> wrote:
>
> ºÇºÇ£¬Ð»Ð»°¡£¬¿ÉϧÎÒÕ⻹Óò»µ½Ç°Ì¨µÄjavascript¼¼Êõ¡£
> »¹ÓÐÒ»¸ö£¬ÎÒ¸Õ·¢ÏÖ£¬ÓÃminidom ½âÎö±È½Ï´óµÄxmlÎļþ£¬ÏñÎÒÕâ¸ö10mÒÔÉϵģ¬¾ÍºÜ²»ºÏÊÊÁË¡£
>
> ÔÚ07-3-5£¬…d„^…d <wanliyou at gmail.com > дµÀ£º
> >
> > XML={};
> > XML.newDocument = function(rootTagName, namespaceURL) {
> >     if (!rootTagName) rootTagName = "";
> >     if (!namespaceURL) namespaceURL = "";
> >
> >     if (document.implementation &&
> > document.implementation.createDocument) {
> >         // W3C standard way
> >         return document.implementation.createDocument(namespaceURL,
> > rootTagName, null);
> >     }
> >     else { // IE way
> >         var doc = new ActiveXObject(" MSXML2.DOMDocument");
> >         if (rootTagName) {
> >             var prefix = "";
> >             var tagname = rootTagName;
> >             var p = rootTagName.indexOf(':');
> >             if (p != -1) {
> >                 prefix = rootTagName.substring(0, p);
> >                 tagname = rootTagName.substring(p+1);
> >             }
> >             if (namespaceURL) {
> >                 if (!prefix) prefix = "a0"; // What Firefox uses
> >             }
> >             else prefix = "";
> >             var text = "<" + (prefix?(prefix+":"):"") +  tagname +
> >                 (namespaceURL
> >                  ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
> >                  :"") +
> >                 "/>";
> >             // And parse that text into the empty document
> >             doc.loadXML(text);
> >         }
> >         return doc;
> >     }
> > };
> >
> > ÕâÊÇjavascriptн¨Ò»¸öXML
> > doc¶ÔÏóºÍµ¼Èëtext/stringµÄ¹ý³Ì¡£Èç¹ûÊǸöAjaxÓ¦Óã¬Õâ¸ö¿ÉÒÔÓÃXMLHttpRequestÀ´Í¬²½½Úµã¡£
> >
> > PythonÀïµ¥´¿Îı¾´¦Àí from xml.dom.minidom import parse, parseString
> >
> > Ï£Íû¶ÔÄãÓÐÓÃ
> >
> >
> > On 3/5/07, hch <huangchonggnu at gmail.com> wrote:
> > >
> > > ÏÖÔÚÄܰѽڵãͨ¹ýtoxml()·½·¨×Ö·û´®»¯ÁË£¬µ«ÊÇ´«µ½server¶Ëʱ£¬ÓÖÈçºÎ°ÑËüÃÇ»¹Ô­³É½Úµã¶ÔÏóµÄÁбíÄØ£¿
> > >
> > >
> > > ...... line 33, in receive
> > >     firstChildNode.appendChild(id)
> > >
> > >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py",
> > > line 117, in appendChild
> > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > >
> > > AttributeError: 'str' object has no attribute 'nodeType'
> > >
> > > »¹ÊÇÕâ¸ö±¨´í¡£ºÃÏñ¾ÍÊÇÒòΪ´«µÝ¹ýÈ¥µÄÊÇid×Ö·û´®¶ÔÏó£¬ËùÒÔappendChild(id),²»¹ÜÓÃÄÄ
> > >
> > > ÔÚ07-3-5£¬ …d„^…d <wanliyou at gmail.com> дµÀ£º
> > > >
> > > > ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©
> > > >
> > > > On 3/5/07, hch < huangchonggnu at gmail.com> wrote:
> > > > >
> > > > >
> > > > > ²éÁËxml.dom.minidomµÄapi£¬
> > > > > »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer at gmail.com> дµÀ£º
> > > > > >
> > > > > > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> > > > > >
> > > > > >
> > > > > > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> > > > > >
> > > > > > ÔÚ07-3-2£¬ hch <huangchonggnu at gmail.com> дµÀ£º
> > > > > > >
> > > > > > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > > > > >
> > > > > > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer at gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > > > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > > > > >
> > > > > > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > > > > > >
> > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > > > >
> > > > > > > > > ÄÇô°Ñelement
> > > > > > > > > ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > > > > > >
> > > > > > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou at gmail.com> дµÀ£º
> > > > > > > > > >
> > > > > > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 3/2/07, hch <huangchonggnu at gmail.com > wrote:
> > > > > > > > > > >
> > > > > > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > > > > > urllib2.urlopen("http://%s/receive.py/receive" %
> > > > > > > > > > > ServerIp , param)
> > > > > > > > > > >
> > > > > > > > > > > server¶Ë£º
> > > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > > firstChildNode = Dom.firstChild
> > > > > > > > > > > for id in ID_LIST:
> > > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > > > fd = open(f, 'w')
> > > > > > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > > > > > fd.close()
> > > > > > > > > > >
> > > > > > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > > > > > >   ...... line 33, in receive
> > > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > > >
> > > > > > > > > > >   File
> > > > > > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > > > > > appendChild
> > > > > > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > > > > > >
> > > > > > > > > > > AttributeError: 'str' object has no attribute
> > > > > > > > > > > 'nodeType'
> > > > > > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer at gmail.com> дµÀ£º
> > > > > > > > > > > >
> > > > > > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > > > > >
> > > > > > > > > > > > strcut{
> > > > > > > > > > > > int size;
> > > > > > > > > > > > string xml;
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu at gmail.com> дµÀ£º
> > > > > > > > > > > > >
> > > > > > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > > > > > 
> > > > > > > > > > > > > ...
> > > > > > > > > > > > > ......
> > > > > > > > > > > > > ...
> > > > > > > > > > > > > 
> > > > > > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > > > > > >
> > > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > > python-chinese
> > > > > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > devdoer
> > > > > > > > > > > > devdoer at gmail.com
> > > > > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > python-chinese
> > > > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > _______________________________________________
> > > > > > > > > > > python-chinese
> > > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > > Detail Info:
> > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > ------======Nerazzurri======------
> > > > > > > > > > _______________________________________________
> > > > > > > > > > python-chinese
> > > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > > Detail Info:
> > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > devdoer
> > > > > > > > devdoer at gmail.com
> > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request at lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese at lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request at lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > devdoer
> > > > > > devdoer at gmail.com
> > > > > > http://devdoer.blog.sohu.com/
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese at lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request at lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > ------======Nerazzurri======------
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > ------======Nerazzurri======------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
------======Nerazzurri======------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/2082576a/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 15:26

hch huangchonggnu在gmail.com
星期一 三月 5 15:26:11 HKT 2007

µ«ÊÇminidom£¬ºÍexpat, libxml2, elementTree±ÈÆðÀ´£¬Ð§ÂʾÍÌ«µÍÁË°É
http://www.ibm.com/developerworks/cn/xml/x-matters/part28/index.html
½ü×÷²Î¿¼

ÔÚ07-3-5£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
>
> from xml.dom.minidom import parse, parseString
> ²»ÐÐô£¿
> ʲô¶«Î÷¸É¸ö10MµÄÎı¾¶¼²»»áÌ«¿ì¡£¡£¡£
>
> On 3/5/07, hch < huangchonggnu在gmail.com> wrote:
> >
> > ºÇºÇ£¬Ð»Ð»°¡£¬¿ÉϧÎÒÕ⻹Óò»µ½Ç°Ì¨µÄjavascript¼¼Êõ¡£
> > »¹ÓÐÒ»¸ö£¬ÎÒ¸Õ·¢ÏÖ£¬ÓÃminidom ½âÎö±È½Ï´óµÄxmlÎļþ£¬ÏñÎÒÕâ¸ö10mÒÔÉϵģ¬¾ÍºÜ²»ºÏÊÊÁË¡£
> >
> > ÔÚ07-3-5£¬…d„^…d < wanliyou在gmail.com > дµÀ£º
> > >
> > > XML={};
> > > XML.newDocument = function(rootTagName, namespaceURL) {
> > >     if (!rootTagName) rootTagName = "";
> > >     if (!namespaceURL) namespaceURL = "";
> > >
> > >     if (document.implementation &&
> > > document.implementation.createDocument) {
> > >         // W3C standard way
> > >         return document.implementation.createDocument(namespaceURL,
> > > rootTagName, null);
> > >     }
> > >     else { // IE way
> > >         var doc = new ActiveXObject(" MSXML2.DOMDocument");
> > >         if (rootTagName) {
> > >             var prefix = "";
> > >             var tagname = rootTagName;
> > >             var p = rootTagName.indexOf(':');
> > >             if (p != -1) {
> > >                 prefix = rootTagName.substring(0, p);
> > >                 tagname = rootTagName.substring(p+1);
> > >             }
> > >             if (namespaceURL) {
> > >                 if (!prefix) prefix = "a0"; // What Firefox uses
> > >             }
> > >             else prefix = "";
> > >             var text = "<" + (prefix?(prefix+":"):"") +  tagname +
> > >                 (namespaceURL
> > >                  ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
> > >                  :"") +
> > >                 "/>";
> > >             // And parse that text into the empty document
> > >             doc.loadXML(text);
> > >         }
> > >         return doc;
> > >     }
> > > };
> > >
> > > ÕâÊÇjavascriptн¨Ò»¸öXML
> > > doc¶ÔÏóºÍµ¼Èëtext/stringµÄ¹ý³Ì¡£Èç¹ûÊǸöAjaxÓ¦Óã¬Õâ¸ö¿ÉÒÔÓÃXMLHttpRequestÀ´Í¬²½½Úµã¡£
> > >
> > > PythonÀïµ¥´¿Îı¾´¦Àí from xml.dom.minidom import parse, parseString
> > >
> > > Ï£Íû¶ÔÄãÓÐÓÃ
> > >
> > >
> > > On 3/5/07, hch <huangchonggnu在gmail.com> wrote:
> > > >
> > > > ÏÖÔÚÄܰѽڵãͨ¹ýtoxml()·½·¨×Ö·û´®»¯ÁË£¬µ«ÊÇ´«µ½server¶Ëʱ£¬ÓÖÈçºÎ°ÑËüÃÇ»¹Ô­³É½Úµã¶ÔÏóµÄÁбíÄØ£¿
> > > >
> > > >
> > > > ...... line 33, in receive
> > > >     firstChildNode.appendChild(id)
> > > >
> > > >   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py",
> > > > line 117, in appendChild
> > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > >
> > > > AttributeError: 'str' object has no attribute 'nodeType'
> > > >
> > > > »¹ÊÇÕâ¸ö±¨´í¡£ºÃÏñ¾ÍÊÇÒòΪ´«µÝ¹ýÈ¥µÄÊÇid×Ö·û´®¶ÔÏó£¬ËùÒÔappendChild(id),²»¹ÜÓÃÄÄ
> > > >
> > > > ÔÚ07-3-5£¬ …d„^…d <wanliyou在gmail.com> дµÀ£º
> > > > >
> > > > > ÕýÔòÇÐÎı¾£¬°ÑÄǶÎÎı¾·¨¹ýÈ¥£¬Ã²ËÆûÓз¢ËÍ"½Úµã"µÄ¹¦ÄÜ£¨£¿£©
> > > > >
> > > > > On 3/5/07, hch < huangchonggnu在gmail.com> wrote:
> > > > > >
> > > > > >
> > > > > > ²éÁËxml.dom.minidomµÄapi£¬
> > > > > > »¹ÊDz»ÖªµÀ¸ÃÔõô×Ö·û´®»¯£¬normalize()ºÃÏñ²»ÄÜÓã¬ÄÄλ֪µÀµÄÄܸæËßСµÜÒ»ÏÂÂ𣿻¹ÓÐÄÜͨ¹ýÍøÂç´«dom½ÚµãÂð£¬Ð¡µÜ¶ÔÕâ¸öÒ»Ö±²»È·¶¨¡£Ë­ÄܸæËßÎÒ¹þ¡£
> > > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > > > > > >
> > > > > > > Ôõô×Ö·û´®»¯£¿²é python xmlµÄapiÊÖ²á
> > > > > > >
> > > > > > >
> > > > > > > "Dom = xml.dom.minidom.parse(f)" fÓ¦¸ÃÊÇÒ»¸öÓï·¨ÕýÈ·µÄxmlÎı¾£¬
> > > > > > >
> > > > > > > ÔÚ07-3-2£¬ hch <huangchonggnu在gmail.com> дµÀ£º
> > > > > > > >
> > > > > > > > °ÑDom Element Ö±½Ó´«¹ýÈ¥ÊÇÐв»Í¨µÄ£¬Òª°ÑËüÃÇ×Ö·û´®»¯¡£¿ÉÊÇÎÒ²»ÖªµÀ¸ÃÔõô×Ö·û´®»¯Ñ½¡£
> > > > > > > >
> > > > > > > > "×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID"£¬ÄѵÀ×Ö·û´®»¯ÒÔºó»¹Òª´æµ½ÎļþÀïÈ¥Âð£¬ÎªÊ²Ã´²»Ö±½Ó´«µ½server¶ËÄØ£¿²»Ã÷°×ÄãµÄÒâ˼ѽ
> > > > > > > >
> > > > > > > > ÔÚ07-3-2£¬ bird devdoer < devdoer在gmail.com> дµÀ£º
> > > > > > > > >
> > > > > > > > > Äã´«µÄÊÇ×Ö·û´®°¡£¬½ÓÊÕºó½âÎöÒ»ÏÂ
> > > > > > > > > °´ÕÕÄã³ÌÐòµÄÒâ˼£¬ÄãÓ¦¸Ã»¹Òª×Ô¶¨ÒåÒ»¸öxmlÎı¾À´±£´æÐÂÔöµÄID£¬È»ºóxml×Ö·û´®´«¸øserver¶Ë£¬server¶ËÔÙÓÃ
> > > > > > > > >
> > > > > > > > > xml½âÎöÆ÷½âÎöÒ»ÏÂ
> > > > > > > > >
> > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > > > >
> > > > > > > > > > ÄÇô°Ñelement
> > > > > > > > > > ת³Éstring£¬ÊDz»ÊÇͨ¹ýpickleÄØ?»¹ÓУ¬Õâ¸ölist×îºóҲҪת³ÉstringÂ𣿻¹Çë¶àÖ¸µãһϰ¡
> > > > > > > > > >
> > > > > > > > > > ÔÚ07-3-2£¬…d„^…d <wanliyou在gmail.com> дµÀ£º
> > > > > > > > > > >
> > > > > > > > > > > ´«µÄÊÇstring,ÓÖ²»ÊÇelement£¬ÀÏÀÏʵʵ°Ñstring¶¼·¢¹ýÈ¥£¬ÔÙload³É¿ÉÒÔdom²Ù×÷µÄxml¶ÔÏó£¬×îºóappend
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 3/2/07, hch <huangchonggnu在gmail.com > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > ÎÒÖ±½Ó´«ÁÐ±í£¬´úÂëÊÇÕâÑùµÄ£¬client¶Ë
> > > > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > > > idNodeList = Dom.getElementsByTagName ('id')
> > > > > > > > > > > > idList = idNodeList[addedStartLocation:]
> > > > > > > > > > > > param = "ID_LIST=%s" % idList
> > > > > > > > > > > > urllib2.urlopen("http://%s/receive.py/receive" %
> > > > > > > > > > > > ServerIp , param)
> > > > > > > > > > > >
> > > > > > > > > > > > server¶Ë£º
> > > > > > > > > > > > Dom = xml.dom.minidom.parse(f)
> > > > > > > > > > > > firstChildNode = Dom.firstChild
> > > > > > > > > > > > for id in ID_LIST:
> > > > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > > > > fd = open(f, 'w')
> > > > > > > > > > > > Dom.writexml(fd, encoding='utf-8')
> > > > > > > > > > > > fd.close()
> > > > > > > > > > > >
> > > > > > > > > > > > ±¨´íÊÇÕâÑùµÄ
> > > > > > > > > > > >   ...... line 33, in receive
> > > > > > > > > > > >     firstChildNode.appendChild(id)
> > > > > > > > > > > >
> > > > > > > > > > > >   File
> > > > > > > > > > > > "/usr/lib/python2.3/site-packages/_xmlplus/dom/minidom.py", line 117, in
> > > > > > > > > > > > appendChild
> > > > > > > > > > > >     if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
> > > > > > > > > > > >
> > > > > > > > > > > > AttributeError: 'str' object has no attribute
> > > > > > > > > > > > 'nodeType'
> > > > > > > > > > > > ÎÒ¾õµÃºÍ¶ÔÏóÐòÁл¯ÓйØϵѽ
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ÔÚ07-3-2£¬bird devdoer <devdoer在gmail.com> дµÀ£º
> > > > > > > > > > > > >
> > > > > > > > > > > > > ²»Ã÷°×ÄÑÔÚÄÄÀ²»¾ÍÊÇÒ»¸ö×Ö·û´®×Ö½ÚÁ÷ô£¬Ö±½Ó´«²»¾Í¿ÉÒÔÁË£¬µ±È»Òª×¢ÒâÏàÁÚ×Ö·û´®µÄ±ß½ç£¬¿ÉÒÔÔ¤¶¨ÒåÒ»¸ö¼òµ¥µÄ°ü¸ñʽ
> > > > > > > > > > > > >
> > > > > > > > > > > > > strcut{
> > > > > > > > > > > > > int size;
> > > > > > > > > > > > > string xml;
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > ÔÚ07-3-2£¬hch < huangchonggnu在gmail.com> дµÀ£º
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > ´ó¼ÒºÃ£¬Ð¡µÜÓÐÒ»¸öÎÊÌ⣬ÊÇÕâÑùµÄ£¬
> > > > > > > > > > > > > > clientÓëweb serverÿ¸ô1·ÖÖÓ£¬ÒªÍ¬²½Ò»xmlÎļþ¡£xml¸ñʽ´ó¸ÅÊÇÕâÑùµÄ
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > ...
> > > > > > > > > > > > > > ......
> > > > > > > > > > > > > > ...
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > clientµÄidÌõÄ¿ÔÚ²»¶ÏÔö¼Ó£¬¿¼Âǵ½Õâ¸öÎļþ»á´ïµ½ÉÏ°ÙÕ×£¬ÖØ´«Ò»´ÎºÜºÄʱ¡£ËùÒÔÖ»°ÑÐÂÔöµÄidÌõÄ¿È¡³ö£¬Ìí¼Óµ½·þÎñÆ÷¶ËµÄxmlÀï¡£
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > ÎÒµÄÏë·¨ÊÇ£¬°ÑÐÂÔöµÄidÌõÄ¿×é³ÉÒ»ÁÐ±í£¬°ÑÕâ¸öÁÐ±í´«µÝµ½server¶Ë£¬
> > > > > > > > > > > > > > ͨ¹ýxml.dom.minidomÀïµÄ.appendChild¸üÐÂxmlÎļþ
> > > > > > > > > > > > > > ¡£¿ÉÊÇÕâ¸ö½Úµã¶ÔÏóµÄÁбí¸ÃÔõô´«¹ýÈ¥ÄØ£¬ÊDz»ÊǸÃÓÃpickle£¨¶Ô¶ÔÏóÐòÁл¯ºÜ²»Ê죩£¬ÄÄλÄܸøÎÒÖ¸µãһϷ½Ïò£¬Ð»Ð»^^
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > > > python-chinese
> > > > > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > devdoer
> > > > > > > > > > > > > devdoer在gmail.com
> > > > > > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > > python-chinese
> > > > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _______________________________________________
> > > > > > > > > > > > python-chinese
> > > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > > Detail Info:
> > > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > ------======Nerazzurri======------
> > > > > > > > > > > _______________________________________________
> > > > > > > > > > > python-chinese
> > > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > > Detail Info:
> > > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _______________________________________________
> > > > > > > > > > python-chinese
> > > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > > Detail Info:
> > > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > devdoer
> > > > > > > > > devdoer在gmail.com
> > > > > > > > > http://devdoer.blog.sohu.com/
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > python-chinese
> > > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > > Subscribe: send subscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > > Detail Info:
> > > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > python-chinese
> > > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > > Subscribe: send subscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > > python-chinese-request在lists.python.cn
> > > > > > > > Detail Info:
> > > > > > > > http://python.cn/mailman/listinfo/python-chinese
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > devdoer
> > > > > > > devdoer在gmail.com
> > > > > > > http://devdoer.blog.sohu.com/
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > python-chinese
> > > > > > > Post: send python-chinese在lists.python.cn
> > > > > > > Subscribe: send subscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Unsubscribe: send unsubscribe to
> > > > > > > python-chinese-request在lists.python.cn
> > > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > python-chinese
> > > > > > Post: send python-chinese在lists.python.cn
> > > > > > Subscribe: send subscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Unsubscribe: send unsubscribe to
> > > > > > python-chinese-request在lists.python.cn
> > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > ------======Nerazzurri======------
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > >
> > > --
> > > ------======Nerazzurri======------
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> ------======Nerazzurri======------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070305/c2d1cbc2/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月05日 星期一 15:35

麦田守望者 qcxhome在gmail.com
星期一 三月 5 15:35:05 HKT 2007

On 3/5/07, hch <huangchonggnu at gmail.com> wrote:
> 但是minidom,和expat, libxml2, elementTree比起来,效率就太低了吧
> http://www.ibm.com/developerworks/cn/xml/x-matters/part28/index.html
> 近作参考
>

没错。如果不需要随机访问dom中的节点,就没有必要使用它解析XML文档。

-- 
GoogleTalk: qcxhome at gmail.com
MSN: qcxhome at hotmail.com
My Space: tkdchen.spaces.live.com
BOINC: boinc.berkeley.edu
中国分布式计算总站: www.equn.com

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号