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
1. Use XmlBeanFactory to read the spring configuration file:
Resource resource=new ClassPathResource("conf/spring/applicationContext.xml"); BeanFactory factory=new XmlBeanFactory(resource); com.geostar.query.beans.DataSource ds=(com.geostar.query.beans.DataSource)factory.getBean("ds");System.out.println(ds.getDriverClassName());
Console:
Log4j: WARN No such property [maxBackupIndex] in org. apache. log4j
/**
* Gets the value of the specified property in the configuration file
* @param the name of the property in the key profile
* @return Returns the value of the property
/protected String GetProperty ( String key)
{
string[] ConfigValue = getProperties (key);
return configvalue[0];
}
/**
* Gets the corresponding value of all the properties in the configuration file
* @return Returns an
XML file
PHP parsing XML Gets the value in the tag
* * _get_xml acquired XML file * @access Public representation function External * @param $_xmlfile XML file * $_ht
Provides the simplest ASP tutorial. NET Read XML code program
New XDocument (
New XElement ("Ol",
From item in Xdocument.load (Http://111cn.net/update.xml). Descendants ("item")
Select New xelement[]{
New XElement ("Li",
New XElement ("A", (string) item.element ("title"),
New XAttribute ("href", (string) item.element ("link")
)
)
}
)
)
Web|xml uses (ii) the two functions I wrote (in package SRC) to implement the Web page operation.
Index.html:
Value= "C:\\eclipse\\workspace\\myxml\\xmldata\\11.xml" >
Page create.jsp to write:
String Mypath= (String) request.getparameter ("MyPath");
String mytitle= (String) request.getparameter ("MyTitle");
String mycontent= (String) request.getparameter ("mycontent");
Mypath=new String (mypath.get
# 1.34BUnited States # Washington D.C. # 0.31B
3. Use other separator numbers and skip some rows. For more information, see here: Click to open the link.
CSVReader reader = new CSVReader (new FileReader (file ),';')CSVReader reader = new CSVReader (new FileReader (file ),'#')
Skip the first five rows, starting from the first 6th rows:
CSVReader reader = new CSVReader(new FileReader(
First, describeDevelop a MyFrame form application that inherits the JFrame class, the title in the form, the text on the button, and so on can be written in an XML configuration file, even if you want to change all of the properties later, you only need to change the corresponding attribute in the XML configuration file.This case uses the properties class in
This paper mainly introduces the knowledge of C # reading and writing XML, which has a good reference value. Let's take a look at the little series.
Read XML
XmlDocument xd = new XmlDocument (); String fileName = @ "D:\test.xml"; Xd. Load (fileName); XmlNodeList xmlnotelist = xd. getElementsByTagName ("user"); list
Write
Read the file:
Copy Code code as follows:
#!perl
Open Filetxt, "/path/a.txt"; # filetxt is a file handle used to establish a link to the file a.txt. The file handle can
you can see the Code bound to an XML segment of your predecessors. The code is simplified and pasted for learning. # bind a sound file to region string sounddef = server. mappath (request. applicationpath + "/sound/soundconfig. XML "); dataset dssound = new dataset ();
Read code:[email protected] 03]# cat ex03-read-01.c/* File ex03-open-03.c,Use of O_creat and O_EXCL * *#include #include #include #include int main (void){int FD = -1,i;ssize_t size =-1;/* buffer for storing data */Char buf[10];Char filename[] = "test.txt";/* Open file, if
Java code relies on a new set of Java methods and associated APIs, which are still under development. Data binding is a "Java specification requirement" built by Sun (JSR-031, see Resources) designed to make it easier for Java objects to bind to
Java EE load XML fileResource interface, which is the interface used to load files.Both Filesystemresource and Classpathresource implement the resource interface, which they can use to load XML files.The specific code is as follows:1 New Classpathresource ("file.
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.