Using Dom to parse XML in QT (Summary)
A few days ago, due to a change in the underlying topology, the topology file was changed. The parsing operations on the topology file I was responsible for would naturally have to be re-initiated. I used the last weekend to complete this task. By the way, I also used this time to summarize the learned knowledge.We know that there are only two ways to read and
Using Builder to create XML
Builder installation Method:
Gem Install Builder
Require ' builder '
x = builder::xmlmarkup.new (: Target =>
$stdout,: Indent => 1)
# ": Target => $stdout" Parameters: Indicates that the output
will be written to the standard output console
# ": Indent =>1" parameter: The XML output form will be indented
into a space character x.instruct!:
XMLWriter (new FileWriter (file), format);Writer.write (document);} finally{if (writer! = null)Writer.close ();}}}After running it can be in c:/ Found the same department.xml as the contents of the 5.2.1 file.Here are two points to keep in mind:(1) OutputFormat format = OutputFormat. Createprettyprint ()XML is often required to be read, dom4j default generation format is condensed format, this can reduce space consumption, but the disadvantage is tha
A large number of SmipleXML functions can be used to load and parse a large number of XML documents.
--------------------------------------------------------------------------------
1.
SimpleXML_load_file ()Function to load the specified XML file to the object. If a problem occurs during file loading, FLASE is returned. Example:
Book.
When writing Ajax, it is often necessary to parse a string returned from the server. Here we will briefly introduce two formats of characters returned by the server and the parsing methods of Js for them.
I. JSON
JavaScript Object Notation (JavaScript Object Notation) is a string that is combined by declaring objects in Js.JS can define objects as follows:
Parse XML and xmljava
1. parse the XML String of the String type to obtain the attribute value.
String resultXML = "
......
/Result> ";
(1) obtain the value of value in message
//
In. net, the Program for writing and reading XML prompts "the instance of the object has not been referenced", it was a bit strange at the time. why do we need to instantiate an object when reading XML data. google knows that xmlns is added to the XML file to indicate the namespace, but XPath must also be added.
For example, our
parameter value, *method is the method name, and xmlns is the namespace * / Public void Initsoap(String arg1,string arg2,string arg3,string arg4,string method,string xmlns) {String
A large number of smiplexml functions can be used to load and parse a large number of XML documents.
--------------------------------------------------------------------------------
1.
simplexml_load_file ()function to load the specified XML file into the object. If you are having trouble loading the file, return flase. Cases:
Book.xml file:
Copy CodeThe code is
sub-tags. For example:
You can use the following code:
while (eventType != XmlPullParser.END_TAG) { switch (eventType) { case XmlPullParser.START_TAG: tag = parser.getName(); final String content = parser.nextText(); Log.e(TAG, tag + ": [" + content + "]"); eventType = parser.nextTag(); break; default: break;
Android pull is the easiest way to parse xml
Android pull is the easiest way to parse xml
177571349
177477683
Public static List
GetPull (String pid, int page) throw
JDOM is a unique Java toolkit that uses XML to quickly develop XMLApplicationProgram. Its design includes the syntax and even semantics of the Java language.
Click to download the JDOM jar package
I made a Java project example to introduce the file structure first:
My XML
First, use the Saxreader way to parse: instance test class Testxml
Package *
Import Java.io.ByteArrayInputStream;Import Java.util.Iterator;
Import org.dom4j.Document;Import org.dom4j.Element;Import Org.dom4j.io.SAXReader;
public class Testxml {
/*** @param args*/public static void Main (string[] args) {try {TODO auto-generated Method StubDefines the XML
Recently, according to the instructor's requirements, I made a small file for parsing XML files, capturing HTML webpages, and parsing webpages.Program. But it took a week. There are many gains, and practice is the only criterion to test truth.
1. The first choice is C ++ (a familiar language ).Programming Language), The result shows that the open-source C ++ library is small.
2. There are still some C ++ libraries for parsing
If XML is parsed in the main thread, the XML is parsed into a string and parsed; Ui updates in the main thread should not be processed too much. You can use another method; Otherwise, it will cause too much work in the main thread and stop running. Private List Parse (strin
;
Here is a small note: enginuity: viewcontrol indicates that the namespace of viewcontrol is enginuity.
The Value Attribute Value of the textbox node whose name is text_10 is ABC.
About selectsinglenode method you can refer to: http://msdn.microsoft.com/en-us/library/h0hw012b.aspx
This method has two parameters. The first one is string XPath., This is required, and the second isXmlnamespacemanager nsmgr, which is optional.The most important th
This article provides a detailed analysis of the use of SimpleXML functions to load and parse XML documents. For more information, see a large number of SmipleXML functions.
--------------------------------------------------------------------------------
1.
SimpleXML_load_file ()Function to load the specified XML file to the object. If a problem occurs during Fil
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.