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

[Perl]ÀûÓÃXML::DOMÉú³ÉXMLÎĵµ

PerlµÄXML::DOM¹¦ÄܺÜÇ¿´ó£¬ÀûÓÃËü¿ÉÒÔÇáÒ׵طÖÎöXMLÎĵµ£¬Ò²¿ÉÒÔ½¨Á¢XMLÎĵµ¡£
³£ÓõÄÀà°üÀ¨£º
XML::DOM::Node£ºËùÓÐÀàµÄ»ùÀ࣬±íʾһ¸öXML½Úµã¡£
XML::DOM::Parser£ºXML½âÎöÆ÷£¬½«XML×Ö·û´®½âÎö³ÉXML::DOM::Document¶ÔÏó¡£
XML::DOM::Document£ºÖ¸ÏòXMLÎĵµµÄ¸ù½Úµã¡£
XML::DOM::Element£ºÖ¸ÏòÒ»¸öÔªËØ£¬Í¨³£ÓÉXML::DOM::Document->createElementÔªËØÉú³É¡£
ÆäËûµÄÀà¿ÉÒԲ鿴CPAN
ÉϹØÓÚ XML::DOM µÄ˵Ã÷¡£
½¨Á¢XMLÎĵµµÄͨ³£×ö·¨ÊÇ£ºÊ×ÏÈͨ¹ý XML::DOM::ParserÉú³ÉÒ»¸öDocument¶ÔÏó£¬
ÔÙͨ¹ýÕâ¸öDocument¶ÔÏóµÄ createElement¡¢createTextNode µÈ·½·¨Éú³É¸÷¸ö½Úµã£¬
×îºóͨ¹ý XML::DOM::Node->appendChild ·½·¨½«½ÚµãÌí¼Óµ½Document¶ÔÏóÖУ¬
×îºóÔÙͨ¹ý toString ·½·¨½« Document ת»»Îª×Ö·û´®Êä³ö¡£
ÏÂÃæÊǽ¨Á¢XMLÎĵµµÄÒ»¸öÀý×Ó£º
#!/usr/bin/perl
use XML::DOM;
use XML::Twig;
# ´´½¨XMLµÄ×îÍâ²ãÔªËØ
my $xml = "<MyXML/>";
# ͨ¹ýXML::DOM::Parser½âÎöÍâ²ãÔªËØ£¬´´½¨»ù´¡XMLÎĵµ
# XML::DOM::Parser::parseº¯ÊýµÄ·µ»ØֵΪ XML::DOM::Document Àà
my $parser = new XML::DOM::Parser;
my $dom = $parser->parse($xml);
# Éú³ÉBook½Úµã
# createElementµÄ·µ»ØֵΪ XML::DOM::Element Àà
# XML::DOM::Element µÄ¸¸ÀàÊÇ XML::DOM::Node Àà
my $book = $dom->createElement("Book");
# ÉèÖýڵãÊôÐÔ
$book->setAttribute("title", "My First Book");
$book->setAttribute("author", "charlee");
# Éú³ÉChapter½Úµã
my $chapter = $dom->createElement("Chapter");
$chapter->setAttribute("id", "1");
# Éú³ÉÒ»¸öÎı¾½Úµã
my $title = $dom->createTextNode("My First Chapter");
$chapter->appendChild($title);
# Ìí¼ÓChapterµ½Book
$book->appendChild($chapter);
# Ìí¼ÓBookµ½XMLÎĵµ
$dom->getDocumentElement->appendChild($book);
# ÀûÓÃXML::TwigÕûÀí¸ñʽ
my $twig = new XML::Twig;
$twig->set_indent(" "x4);
$twig->parse($dom->toString);
$twig->set_pretty_print("indented");
# Êä³ö
print $twig->sprint;
×îºóÒ»¶ÎʹÓÃXML::TwigµÄ³ÌÐòÖ»ÊÇΪÁËÕûÀíXMLÊä³ö½á¹ûµÄ¸ñʽ£¬
Èç¹û²»ÐèÒªÕûÀí¸ñÊ


Ïà¹ØÎĵµ£º

xml½âÎö

xml
<mime>
<content>
<type>text/plain</type>
<big>357</big>
<text>D:\\cybercourttext2009101410241364.txt</text>
</content>
<content>
<type>text/plain</type>
<big>357</big>
<text>D:\\cybercourttext2009 ......

java½âÎöXMLµÄËÄÖÖ·½·¨

XMLÏÖÔÚÒѾ­³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝÓÐDOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Exten ......

vim html xml ×Ô¶¯²¹È«(ÔÚclosetag.vim ÉÏ×÷Á˵ãÐÞ¸Ä)

µ±ÊäÈë ¡·Ê±×Ô¶¯²¹È« µ±ÊäÈ롶/ʱ×Ô¶¯²¹È«
“£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
" File: closetag.vim
" Summary: Functions and mappings to close open HTML/XML tags
" Uses: <C-_> -- close matching open tag
" Author: Steven Mueller <di ......

C# Éú³ÉXMLʱµÄÌØÊâ×Ö·û³öÏÖÒì³£´¦Àí

Éú³É¶Ë´¦Àí
½«ÒªÐ´ÈëµÄÖµµÄÇ°ºóдÉÏÈç:"<![CDATA[" + string+ "]]>";
XmlNode xnformchild = doc.CreateNode(XmlNodeType.Element, dc.ColumnName.ToUpper(), "");
try
{
xnformchild.InnerXml = drform[dc.ColumnName].ToString( ......

C#¶ÔxmlµÄ²Ù×÷ʵÀýÔ´Âë

À©Õ¹±ê¼ÇÓïÑÔXML£¨eXtensible Markup Language£©£¬ÊÇÓÉW3C×éÖ¯Öƶ¨µÄ¡£×öΪÓÃÓÚÌæ´úHTMLÓïÑÔµÄÒ»ÖÖÐÂÐ͵ıê¼ÇÓïÑÔ£¬XMLÄÚ²¿ÓÐןܶà»ù±¾±ê×¼£¬XML¾ÍÊÇͨ¹ýÓëÕâЩÏà¹Ø±ê×¼µØ½áºÏ£¬Ó¦ÓÃÓÚ¿Æѧ¼ÆËã¡¢µç×Ó³ö°æ¡¢¶àýÌåÖÆ×÷ºÍµç×ÓÉÌÎñµÄ¡£C££×÷ΪһÖÖÐÂÐ͵ijÌÐòÓïÑÔ£¬ÊÇ.Net¿ò¼ÜµÄÒ»¸öÖØÒª×é³É²¿·Ö£¬ËûºÍXMLµÄ¹ØϵÆÄÉî¡£±¾ÎÄ¾Í´Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ