This is an example of XML manipulation using the Java common-access DOM, which contains basic operations for querying, adding, modifying, deleting, and saving. A more complete description of an XML's entire operating process. Reference and learning for friends who are just getting started with Java XML operations.
Suppose you have an
possible. But it always feels like a waste of resources. So today I learned a little bit of XML summarized as follows:The 1:xml file is as follows: 2: Tool class for manipulating XML filesXmlutils.javaPackage cn.zyw.utils;Import Java.io.File;Import java.io.FileNotFoundException;Import Java.io.FileOutputStream;Import
This article supporting source code
This case is an example of a VS2005-based WinForm menu control that dynamically loads menu data from XML to the Menutrip control. This case uses techniques such as XML, reflection, and so on. Of course, the practical value is limited, only for learning reference.
First create a WinForm project, place a Menutrip control on the
XML is a text-format-based meta-markup language that focuses on the description of the data structure and meaning, and achieves the separation of data content and display styles (XML + XSL ), it is not related to the platform.
Because XML focuses on the description of data content, it is very meaningful for data retrieval, and we will not retrieve information u
It is known that there is an XML file (bookstore. XML) as follows:
1. Insert a
Xmldocument xmldoc = new xmldocument ();Xmldoc. Load ("Bookstore. xml ");Xmlnode root = xmldoc. selectsinglenode ("Bookstore"); // query Xmlelement xe1 = xmldoc. createelement ("book"); // create a Xe1.setattribute ("genre", "lizan red");
A simple example of XML serialization:
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
// Select the Save path
Private void button#click (object sender, EventArgs e)
{
SaveFileDialog1.Filter = "XML file | *. xml ";
If (saveFileDialog1.ShowDialo
This example is a reference to some of the Web site on JSP on the operation of XML related documents, but also combined with some personal experience. Examples of the content is the development of an enterprise internal catering system backend management part of the code, the function is mainly focused on the restaurant basic information management.
The development of the
XML example of flex acquisition operationsSome examples demonstrate flex's description of common XML operation operators :/******". "," [] ","... "," @ "Four Common E4X operators ******/
// Use the "." operator to query the node and obtain the first subnode. Use "[]" to access the node of the specified index.
// Use the ".." operator to access all nodes named aft
This article mainly introduces how to use xmlreader to read xml data in PHP. This example is relatively simple and only contains one reading function. For more information, see
This article mainly introduces how to use xmlreader to read xml data in PHP. This example is relatively simple and only contains one reading fu
A complete example of XML operations in Java-W3C dom
This is an example of using Java W3C dom for XML, including basic operations for querying, adding, modifying, deleting, and saving. A complete description of the entire XML operation process. It is suitable for users who a
The following is an example of a javabean using XStream to convert XML data into multiple object combinations:
XML Message Format:
......
The following are the relevant Java classes for the corresponding XML:public class Suborderinfo {Private String orderid;//Payment order numberPrivate String amount;//Order AmountPrivate String installmenttimes;//Installment pe
Crossdomain. xml evil usage example
Introduction: This starts *The crossdomain. xml file specifies the access domain name read/write request. This file should be restricted to a trusted website, but not on the spreaker website. Wildcard characters indicate that any site is a
, Parentelm is its parent node
You can also find an article on IBM Developerworks that evaluates the performance, functionality, and usability of the mainstream Java XML API, so you know that dom4j is excellent in any way. Now that more and more Java software is using dom4j to read and write XML, it is particularly worth mentioning that even Sun's JAXM is using DOM4J. This is already the jar package that
To make some data into an XML file, but not on your hard disk, compress the file into a zip format and write it to your hard disk. The final result is: The hard disk has a test.zip file, decompression after the Test.xml file.
Add the.
= document.createTextNode ("Understand Corba");
Converts the node into a child node of the BookName object
Booktitle.appendchild (BookName);
4.4 Converting DOM documents to XML files
Get the converter to convert the DOM document into an XML file, in jdk1.4, there are classes transformerfactory
To implement, the class transformer implements the transformation
1. When importing Jar packages, add Spring-aop-4.2.2.release.jar on the XML configuration (required for Annotations)2. When writing a controller, the annotation need to do the relevant configuration is the red part, and XML is to implement the Controller interface(a) when the annotation is configuredPackage Com.spring.hello;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletre
operation. multiple features such as deletion, modification, and rescheduling are supported.
2. access xml documents through a tree structure
3. moving forward or backward on a node of the tree
Disadvantages
1. transfer the entire document to memory (including useless nodes), wasting time and space
Applicable scenarios
Once the documents are parsed, the data needs to be accessed multiple times. The Hardware Resources (memory and cpu) are sufficient)
build
$link = $dom->createelement ("link");
$linktext = $dom->createtextnode (' http://blog.csdn.net/morewindows/article/details/7102362 ');
$link->appendchild ($linktext);
Then add the
$rootelement->appendchild ($title);
$rootelement->appendchild ($link);
Finally, the
$dom->appendchild ($rootelement);
Such a complete XML is generated. And then complete the entire XML,
echo $dom->savexml ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.