search
HomeDatabaseMysql TutorialOracle包XMLDOM创建XML文件及其缺点

Oracle有一个包XMLDOM,可以很方便的创建XML文件.举个简单的例子.生成Test.xml,内容如下 lt;staff content = name and idg

Oracle有一个包XMLDOM,可以很方便的创建XML文件.举个简单的例子.生成Test.xml,内容如下

   

         

              Arwen

              123

       

         

              Tom

              456

           

  

---------------------------------------------------------------------------------------------------------------------------------------

--生成xml的代码

declare
    doc  XMLDOM.DOMDOCUMENT;
    doc_node  XMLDOM.DOMNODE;
    root_node  XMLDOM.DOMNODE;
    user_node XMLDOM.DOMNODE;
    item_node XMLDOM.DOMNODE;
 
    root_elmt XMLDOM.DOMELEMENT;
    user_elmt XMLDOM.DOMELEMENT;
    item_elmt XMLDOM.DOMELEMENT;

    item_text XMLDOM.DOMTEXT;


 begin
   doc := XMLDOM.NEWDOMDOCUMENT;
   xmldom.setVersion(doc, '1.0');
   xmldom.setCharset(doc, 'UTF-8');
   --根节点
   doc_node := XMLDOM.MAKENODE(doc);
   root_elmt := XMLDOM.CREATEELEMENT(doc,'staff');
   XMLDOM.SETATTRIBUTE(root_elmt,'content ','name and id');
   root_node:=XMLDOM.APPENDCHILD(doc_node, XMLDOM.MAKENODE(root_elmt));
  
   --节点1
   user_elmt := XMLDOM.CREATEELEMENT(doc,'member');
   user_node :=XMLDOM.APPENDCHILD(root_node, XMLDOM.MAKENODE(user_elmt));
  
     item_elmt :=XMLDOM.CREATEELEMENT(doc,'name');
     item_node :=XMLDOM.APPENDCHILD(user_node, XMLDOM.MAKENODE(item_elmt));
     item_text := XMLDOM.CREATETEXTNODE(doc,'Arwen');
     item_node:=XMLDOM.APPENDCHILD(item_node, XMLDOM.MAKENODE(item_text));
    
     item_elmt :=XMLDOM.CREATEELEMENT(doc,'eno');
     item_node :=XMLDOM.APPENDCHILD(user_node, XMLDOM.MAKENODE(item_elmt));
     item_text := XMLDOM.CREATETEXTNODE(doc,'123');
     item_node:=XMLDOM.APPENDCHILD(item_node, XMLDOM.MAKENODE(item_text));
    
     --节点2
     user_elmt := XMLDOM.CREATEELEMENT(doc,'member');
     user_node :=XMLDOM.APPENDCHILD(root_node, XMLDOM.MAKENODE(user_elmt));
  
     item_elmt :=XMLDOM.CREATEELEMENT(doc,'name');
     item_node :=XMLDOM.APPENDCHILD(user_node, XMLDOM.MAKENODE(item_elmt));
     item_text := XMLDOM.CREATETEXTNODE(doc,'tom');
     item_node:=XMLDOM.APPENDCHILD(item_node, XMLDOM.MAKENODE(item_text));
    
     item_elmt :=XMLDOM.CREATEELEMENT(doc,'eno');
     item_node :=XMLDOM.APPENDCHILD(user_node, XMLDOM.MAKENODE(item_elmt));
     item_text := XMLDOM.CREATETEXTNODE(doc,'456');
     item_node:=XMLDOM.APPENDCHILD(item_node, XMLDOM.MAKENODE(item_text));
    
     --写入操作系统文件中
     XMLDOM.WRITETOFILE(doc,'DIR'||'\Test.xml');--注意必须先创建一个文件目录dir
     --可以通过语句 : create or replace directory dir as 'd:\temp'

    

    XMLDOM.FREEDOCUMENT(doc);


 end;

 

这样生成XML文件非常方便,能满足一般的应用了.但是XMLDOM有个缺点,就是一次性在内存中生成所有xml文件内容,然后写入到磁盘文件中.如果xml文件太大,比如说有个table有几个G,想把它保存成xml文件.这样可能就会出现内存不足,生成文件失败.那该咋整呢?

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.