🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.xml
Article #215

��XML Literal���˼��(ת��)

#215
From: <Test/>
Date: Tue, 27 Apr 2010 15:33
39 lines
4974 bytes
 ���ȣ�ʲô��XML Literal�أ�ԭ����������VB.NET 9.0�������һ�����ڹ���XML����������ԣ�����ֻ��VB.NET 9.0��֧�֡����Ƕ�֪����Ҫ����XML��������ʹ��Linq�е�API��������ʾ���������VB.NET 9.0: XML Literal����
Dim _xml2 = New XElement("ProcessList", _
                New XElement("Process", _
                    New XAttribute("ThreadCount", "2"), "Some Process"))
���������Ĵ��룬���ǿ���ʹ�ø�򵥵ķ�ʽ���и�ֵ���Ǿ���ֱ�ӽ�XML��д������
Dim _xml = <Processes>
               <Process ThreadCount="2">Some Name</Process>
           </Processes>
�����VB.NET���е�XML Literal�ˡ�������Բ���������XElement�����Ĺ�̣�����Ҫ���ǣ����ǿ����ڹ����Ĺ�������ijЩ��ѯ��Ʃ������Ĵ��루�������XML Literals Overview����

Dim contact2 = 
        <contact>
          <name>Patrick Hines</name>
          <%= From p In phoneNumbers2 
            Select <phone type=<%= p.Type %>><%= p.Number %></phone> 
          %>
        </contact>
������Щ���ӣ�����ʵ�����ˡ�VB.NET��XML��֧�����ȿ�ν��ǰ����ˣ�����һЩ��ʵ��C#ӵ������˰ݵ���VB.NET��ʯ��ȹ�¡�C#����Ҳ�׷�Ҫ��ΪC#����XML Literal���ԣ��������߽����ҵ���AndersΪ������µĺ��š�����XML Literal����Ȥ�����ѣ������Ķ����¼�ƪ����MSDN�����£�XML Literals Overview��Embedded Expressions in XML��
����XML�Ĵ��?VB.NET�д���������ôIronPython�Ƿ������ƵĹ����أ�Michael�ѳ��ζǡ����䵹����ҵ�������Python��minidomģ�飬���е�parseString����ӵ����΢�ӽ�Ĵ�������������ϧ���ǣ�parseString�������صĶ���ֻ����Document���󣬶��ELement����Ҳ��ζ��parseString����ӵ��XML Literal��ħ����
>>> from xml.dom.minidom import parseString
>>> xmlElement = parseString("""
..     <Processes>
..          <Process ThreadCount="2">Some Name</Process>
..     </Processes>
..   """)
����������IronPython 2.6��ִ�У�����ִ���������ΪIronPython��minidom����ֲ��û��ȫ����ɣ�ȱʧ��ijЩģ�顣�����workaround���£�
1������FePy���ҽ�ѹ��ij��Ŀ¼��Ʃ��D:\FePy��
2����D:\FePy\Lib\pyexpat.py�� D:\FePy\Lib\xml\dom\expatbuilder.py��D:\FePy\Lib\xml\parsers\expat.py��ֵ��IronPython���Ӧ��Ŀ¼�С����һ���ļ��͸��Ƶ�D:\IronPython 2.6\Lib��Ŀ¼�£�
3������expatbuilder.py�е�NewStyle���������ҽ���ɾ��
 
[��ǣ�]һλ��Youtube������ţ��Fredrik Lundh����2002��������ΪPython���XML Literal�Ĺ��ܣ�����ֱ�����ڻ�û�г������ƵĹ��ܣ�����Michael���ڻ�û���ҵ����з��ֵ��������֪һ�����ĸ�л�� 
����limodou�ֵ�ָ�㣬Michael�ҵ���xml.etree.ElementTreeģ�飬���е�xml.etree.ElementTree.XML(text)������һ���̶�ʵ��XML Literal���ԣ��Ͼ���ص���Element������ô���ǾͿ��Ի��ڴ˽��в����ˡ�xml.etree.ElementTreeģ����IronPython 2.6��������
---------------------------------------------------------
ת�ԣ�http://www.cnblogs.com/perhaps/archive/2010/04/24/1719023.html
--
Happy XMLing


�� ��Դ:��ˮľ���� newsmth.net��[FROM: 114.249.210.*]
Technical Details
Message-ID: <4lX934$AzH@newsmth.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!news.neu.edu.cn!news.newsmth.net!NEWSMTH

Show Full Headers
Complete Article Headers
X-Google-Thread: f7ebf7e2af,926d15fcec050c92,start
X-Google-Attributes: gidf7ebf7e2af,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!news.neu.edu.cn!news.newsmth.net!NEWSMTH
From: thinkhy@newsmth.net-SPAM.no (<Test/>)
Newsgroups: cn.bbs.comp.xml
Subject: ��XML Literal���˼��(ת��)
Date: 27 Apr 2010 15:33:04 GMT
Organization: ˮľ����
Message-ID: <4lX934$AzH@newsmth.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: XML/H/M.1272381844.80