<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:XML id="xmlSource">
<node label="grandFather" state="unchecked">
<node label="Father" state="unchecked">
<node label="son" state="unchecked">
<node label="1001" state="unchecked">
<node label="100101" state="unchecked">
</node>
</node>
</node>
</node>
<node label="Uncle3" state="unchecked">
......
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:XML id="xmlSource">
<node label="grandFather" state="unchecked">
<node label="Father" state="unchecked">
<node label="son" state="unchecked">
<node label="1001" state="unchecked">
<node label="100101" state="unchecked">
</node>
</node>
</node>
</node>
<node label="Uncle3" state="unchecked">
......
test.html
————————————————————————————————————————————————————
<HTML>
<HEAD>
<SCRIPT for="window" event="onload">
var xmldoc=xmldso.XMLDocument;
xmldoc.load("conference5.xml");
</SCRIPT>
</HEAD>
<BODY>
<H1 align="center">分页显示XML元素</H1>
<HR size="5" width="80%">
<OBJECT width="0" height="0"
classid="c ......
声明
/// <summary>
/// XML文档
/// </summary>
XmlDocument xmldoc;
/// <summary>
/// XML节点
/// </summary>
XmlNode xmlnode;
/// <summary>
/// XML元素
/// </summary>
XmlElement xmlelem;
XmlElement xmlelem2;
XmlElement xmlelem3;
/// <summary>
& ......
个人收集、整理了一些LINQ TO XML的基本方法,希望各位大虾多多指导:
/// <summary>
///Xml节点属性
/// </summary>
public class XmlAttribute
{
public XmlAttribute()
{
}
public XmlAttribute(string _key,object _value)
{
Key = _key;
Value = _value;
}
/// <summary>
/// 节点属性名
/// </summary>
public string Key { get; set; }
/// <summary>
/// 节点值
/// </summary>
public object Value { get; set; }
}
/// <summary>
///Xml文件节点
/// </summary>
public class XmlNode
{
public XmlNode()
{
  ......
xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia6108">
<wap2>false</wap2>
<width>115</width>
</mobile>
</mobile-list>
-----------------------------------------------------
-----------------------------------------------------
使用jdom读xml文件:
package com.pk.xml;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class JDOMxml {
public static void main(String[] args) throws JDOMException, ......
大量SmipleXML函数可用来加载和解析大量XML文档。
1.simpleXML_load_file()函数来加载指定的XML文件到对象。如果加载文件时遇到问题,则返回FLASE。例:
book.xml文件:
<?xml version="1.0" standalone="yes"?>
<library>
<book>
<title>Pride and Prejudice</title>
<author gender="female">Jane Austen</author>
<description>Jane Austen's most popular work.</description>
</book>
<book>
<title>The Conformist</title>
<author gender="male">Alberto Moravia</author>
<description>Alberto Moravia's classic psyhcological novel.</description>
</book>
<book>
<title>The Sun Also Rises</title>
<author gender="male">Ernest Hemingway</author>
<description>The masterpiece that launched Hemingway's career.</description>
</book>
</library>
php文件:
<?php
/*=====yinyiniao=====*/
$xml=simplexml_load_file("bo ......