Discover java code to read xml file, include the articles, news, trends, analysis and practical advice about java code to read xml file on alibabacloud.com
And if you use XmlReader, you do not need caching, fast reading, but if you want to query is not so convenient, do not support XPath, only through the reader () method forward loop. To avoid the disadvantages of the above two methods, come up with the following scenarios:
1, first use XmlReader to read the contents of the XML file into a linked list.
2, query
The XML file format is as follows:Read a property in a nodeXmlDocument doc=new XmlDocument ();Doc. Load ("config +");XmlNode Xnuser=doc. selectSingleNode ("UserData");String Flag=xnuser. attributes["CreateUser"]. InnerText;Reading values from a nodeXmlDocument doc=new XmlDocument ();Doc. Load ("config +");XmlNode xnserver = doc. selectSingleNode ("Userdata/dataconnection/server");Modify the properties of a
, and the returned subnode object echild is the same, you can insert subnodes at the next level into the child node echild. Finally, call the writexml () method to save it as an XML file.
Ii. Read XML
Import org. JDOM. Document;Import org. JDOM. element;Import org. JDOM. jdomexception;Import org. JDOM. Input. saxbuild
Xml
The following is an example of reading the contents of an XML file and displaying it in a TextBox:
Using System;Using System.Data;Using System.Configuration;Using System.Web;Using System.Web.Security;Using System.Web.UI;Using System.Web.UI.WebControls;Using System.Web.UI.WebControls.WebParts;Using System.Web.UI.HtmlControls;Using System.Xml;Using System.Xml.X
FileWriter and FileReader use the system's current default encoding when writing and reading files.
In the Chinese win under encoding basic is GB2312, in English win under the basic is iso-8859-1. So to create a UTF-8 file, using FileWriter is not possible.
FileWriter and FileReader do not support specifying encoding through parameters, while OutputStreamWriter and InputStreamReader can. These two classes can be seen by name as a combination of byte s
This article describes the method of jquery reading XML file to realize the three-level linkage in the provinces and counties. Share to everyone for your reference. Specifically as follows:
The page code is as follows:
The effect chart is as follows:
I hope this article will help you with your jquery programming.
Recently in the company to do a project, you need to pack the Android interface into the jar package for customer use. For most developers, the layout of the Android interface is based on an XML file and is dynamically tuned with a small amount of Java code. The code that is
the third part (a total of four parts), the basics are explained, and how the code is carefully designed to perform ungroup, and ungroup completes the process of translating XML into Java objects. After you perform a ungroup, you can use the test class, which is included, to check that all parts are grouped together correctly. Each part of this series is based o
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
First, in the appropriate place to add #include #import "Msxml3.dll"using namespace MSXML2;
Second, loading XML document CoInitialize (NULL); Initializing COM, initializing what kind of suite the current thread usesCcomptrCComPtr Spxmldom.cocreateinstance (_uuidof (DOMDocument));The DOMDocument object exposes the following attributes, allowing the user to change the behavior of the parser at run timeSpxmldom-> Put_async (VARIANT_FALSE);Spxmldom-> Put
xml| Hard Drive
Saxreader Saxreader = new Saxreader ();String filename = "d:\\ complement document collation data \\builderXML\\2101invdoc.xml";Document document = Saxreader.read (new File (filename));Chararraywriter out = new Chararraywriter ();OutputFormat format = Outputformat.createprettyprint ();XMLWriter write = new XMLWriter (out, format);Write.write (document);String s = out.tostring ();
Output to c
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.