This article mainly introduces how PHP uses DOM and simplexml to read xml documents, and analyzes related operation skills for creating, loading, and reading xml files using DOM and simplxml in php in combination with examples, for more information about how to use DOM and simplexml to read
Code snippets, code sharing, PHP code sharing, Java code sharing, Ruby code sharing, Python code sharing, HTML code sharing, CSS code sharing, SQL code sharing, and JavaScript code sharing
/*** Get version information and application id from config. xml *** @ param urlPath * @ return * @ throws Exception */public List
GetUpdateInfo () {Resources r = context. getResources (); // use Resources to obtain
PHP uses XmlReader to read XML data samples, Xmlreaderxml
There is an XML file with the following content:
Copy the Code code as follows:
Simpsons
FOX
8:00AM-5:00pm
30
Law Order
This article summarizes the way PHP reads XML format files. Share to everyone for your reference, as follows:
Books.xml file:
DOMDocument method
2. Read the XML with the SAX parser:
3. Parse the XML with a regular expression:
4. Parsing
PHP to generate the test. xml file on drive D (Win7 + XAMPP + IE9.0 passed the test)
II. read XML filesTake the generated D: \ test. xml as an example:
[Php]
// Read the
use myeclipse, one more "/webroot" directory is preset before the WEB-INF, therefore, if some web-independent programs in the web project need to use context (for example, to process the "M" section in some MVC architectures ), xmlwebapplicationcontext cannot be used to read the bean definition file, because the default location will be a "webroot" directory.Tha
PHP XML File Interpretation class application example, Phpxml class application Example
The examples in this paper describe the PHP XML file interpretation class and its usage, which is a very practical technique. Share to everyo
($rootelement);$filename = "D:test.xml";Echo ' XML file Size '. $dom->save ($filename). ' bytes ';?>Running this PHP will generate the Test.xml file on the D drive (Win7 + XAMPP + IE9.0 test pass)
Two Reading an XML fileFor example, re
Else
The first step is to create the parser xml_parser_create (encoding);
$xml = xml_parser_create (' Utf-8 ');
xml_parser_set_option-option settings for the specified XML parsing
Xml_parser_set_option ($xml, Xml_option_case_folding,false); False as output
Register events, which function will be encoun
The. xml file format is as follows
C # Initialization
private static XmlDocument Xmliauconfig; Static ConfigManager () {xmliauconfig = new XmlDocument (); Xmlpath = assembly.getexecutingassembly (). CodeBase; Int32 i = xmlpath.lastindexof ("/"); Xmlpath = Xmlpath.remove (i); Xmlpath = Xmlpath + @ "/abc.xml"; Xmliauconfig.load (Xmlpath); }
Gets the value of a node
public static string GetValue (String key
, all of these are annoying theoretical issues, or quickly cut into the XML configuration file read it.
In our program, there are usually some variables that are determined according to the host environment. For example, the database access username and password, different hosts may be set differently. As long as you
Turn from http://www.jb51.net/article/35230.htm. NET contains a lot of XML-enabled classes that make programmers use XML programming as simple as understanding XML files. In this article, I'll give you an example of a class that is the XmlTextWriter class
The XmlTextWriter class allows you to write
still a very good choice. DOM implementations are widely used in a variety of programming languages. It is also the basis for many other XML-related standards because it is officially recommended by the Consortium (as opposed to a non-standard Java model), so it may be needed in some types of projects (such as using DOM in JavaScript).
3. Sax behaves better, depending on its specific parsing mode-event-dr
At this point, you can send a request to read the XML data on the server. The last thing to do is to process the data. For more information about XMLHttpRequest objects, see the document about XMLHTTPRequest object.
Example:
// Ajaxdemo.html// Data. xml
excellent performance, powerful functionality, and extreme ease of use, is also an open source software. Now you can see that more and more Java software are usingDom4j is used to read and write XML. It is particularly worth mentioning that Sun's jaxm is also using dom4j.
Overview
JDOM and Dom do not perform well in performance tests, and memory overflow occurs
If your applicationcontext. xml file is placed under the WEB-INF:
Use the classpathxmlapplicationcontext class!
ApplicationContext context = new ClassPathXmlApplicationContext("/WEB-INF/applicationContext.xml");
While classpathxmlapplicationcontext this class will eventually look for it under the WEB-INF/classes/directory, after your project is finally deployed, everything under SRC will be deployed under
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.