易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : xml

php获取xml属性值

<!-- xml格式
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
return;
}

$foos = $dom->getElementsByTagName('foo');
$var = $foos->item(0)->getAttribute('xmlns');
echo 'var=' . $var . '<br>';
/*foreach ($foos as $foo)
{
$var = $foo->getAttribute('xmlns');
echo 'var=' . $var . '<br>';
}*/
$bars = $dom->getElementsByTagName('bar');

foreach ($bars as $bar)
{
$arr[] = $bar->getAttribute('attr');
}

var_dump($arr);
?>

  ......

php获取xml属性值

<!-- xml格式
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
return;
}

$foos = $dom->getElementsByTagName('foo');
$var = $foos->item(0)->getAttribute('xmlns');
echo 'var=' . $var . '<br>';
/*foreach ($foos as $foo)
{
$var = $foo->getAttribute('xmlns');
echo 'var=' . $var . '<br>';
}*/
$bars = $dom->getElementsByTagName('bar');

foreach ($bars as $bar)
{
$arr[] = $bar->getAttribute('attr');
}

var_dump($arr);
?>

  ......

php解析xml示例

<!-- xml 格式
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>

<book id='1002'>
<author>congfeng</author>
<title>C++ Designer</title>
<publisher id='bbb'>New Publish</publisher>
</book>
</books>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('books.xml'))
{
echo "load books.xml failed!<br>";
return;
}

$books = $dom->getElementsByTagName('book');
foreach ($books as $book)
{
//get book id
$book_id = $book->getAttribute('id');

//get author
$nodeAuth = $book->getElementsByTagName('author');
$strAuth = $nodeAuth->item(0)->nodeValue;
//get publisher
$nodePub = $book->getElementsByTagName('publisher');
$strPub = $nodePub->item(0)->nodeValue;
$pub_id = $nodePub-&g ......

php解析xml示例

<!-- xml 格式
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>

<book id='1002'>
<author>congfeng</author>
<title>C++ Designer</title>
<publisher id='bbb'>New Publish</publisher>
</book>
</books>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('books.xml'))
{
echo "load books.xml failed!<br>";
return;
}

$books = $dom->getElementsByTagName('book');
foreach ($books as $book)
{
//get book id
$book_id = $book->getAttribute('id');

//get author
$nodeAuth = $book->getElementsByTagName('author');
$strAuth = $nodeAuth->item(0)->nodeValue;
//get publisher
$nodePub = $book->getElementsByTagName('publisher');
$strPub = $nodePub->item(0)->nodeValue;
$pub_id = $nodePub-&g ......

xml,jsp,dtd,xsd 提示信息

进入MyEclipse6.X下
修改:eclipse.ini 文件
-Duser.language=en
改成
-Duser.language=zh
弹出提示:Ctrl+"/"
dtd 命名空间的提示信息
window-->Preference-->xml-->XML Catalog-->add
Location :sql-map-2.dtd
key type :pubic ID
key:-//ibatis.apache.org//DTD SQL Map 2.0//EN (XML文件命名空间)
弹出提示:Ctrl+Space
xsd  命名空间的提示信息
window-->Preference-->xml-->XML Catalog-->add
Location :spring-beans2.0.xsd
key type :Schema Location
key:http://www.springframework.org/schema/beans/spring-beans2.0.xsd
弹出提示:Ctrl+"/" ......

xml,jsp,dtd,xsd 提示信息

进入MyEclipse6.X下
修改:eclipse.ini 文件
-Duser.language=en
改成
-Duser.language=zh
弹出提示:Ctrl+"/"
dtd 命名空间的提示信息
window-->Preference-->xml-->XML Catalog-->add
Location :sql-map-2.dtd
key type :pubic ID
key:-//ibatis.apache.org//DTD SQL Map 2.0//EN (XML文件命名空间)
弹出提示:Ctrl+Space
xsd  命名空间的提示信息
window-->Preference-->xml-->XML Catalog-->add
Location :spring-beans2.0.xsd
key type :Schema Location
key:http://www.springframework.org/schema/beans/spring-beans2.0.xsd
弹出提示:Ctrl+"/" ......

javascript解析返回的xml各式的字符串

<script>
var flags ;
  if(window.XMLHttpRequest) { 
   XMLHttpReq = new XMLHttpRequest(); //firefox下执行此语句
   }
   else if(window.ActiveXObject) {
    try{
    XMLHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
    }catch(e){
     try{
     XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
     }catch(e) {}
    }
   }
   XMLHttpReq.open("post","getDate.jsp",false);
   XMLHttpReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded;charset=UTF-8");
   XMLHttpReq.onreadystatechange = function () {
   var statePending = XMLHttpReq.readyState;
   if (statePending == 4&& XMLHttpReq.status==200)
   {
   &nbs ......

javascript解析返回的xml各式的字符串

<script>
var flags ;
  if(window.XMLHttpRequest) { 
   XMLHttpReq = new XMLHttpRequest(); //firefox下执行此语句
   }
   else if(window.ActiveXObject) {
    try{
    XMLHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
    }catch(e){
     try{
     XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
     }catch(e) {}
    }
   }
   XMLHttpReq.open("post","getDate.jsp",false);
   XMLHttpReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded;charset=UTF-8");
   XMLHttpReq.onreadystatechange = function () {
   var statePending = XMLHttpReq.readyState;
   if (statePending == 4&& XMLHttpReq.status==200)
   {
   &nbs ......

String和Xml之间的转换、String转InputStream

通常在操作xml的时候,都是通过inputstream(很多情况下是FileInputStream)来读入xml并转为dom的,很多人会遇到这种情况数据不是从文件读入的而是从String中取得的
于是会使用
InputStream in = new ByteArrayInputStream (str.getBytes());来取得inputstream ,但是这种InputStream中数据被转成了byte数组,所以转dom的时候就会报错
可以通过一下思路来解决
// 字符串转XML
String xmlStr = \"......\";
StringReader sr = new StringReader(xmlStr);
InputSource is = new InputSource(sr);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc = builder.parse(is);
//XML转字符串
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setOutputProperty(\"encoding\",\"GB23121\");//解决中文问题,试过用GBK不行
ByteArrayOutputStream bos = new ByteArrayOutputStream();
t.transform(new DOMSource(doc), new StreamResult(bos));
String xmlStr = bos.to ......

C#中对XML节点进行增删改查

号称xmlhelper的一个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
/// </summary>
public class XMLHelper
{
public XMLHelper()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region XML文档节点查询和读取
/// <summary>
/// 选择匹配XPath表达式的第一个节点XmlNode.
/// </summary>
/// <param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
/// <param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
/// <returns>返回XmlNode</returns>
public static XmlNode GetXmlNodeByXpath(string xmlFileName, string xpath)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
......

C#中对XML节点进行增删改查

号称xmlhelper的一个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
/// </summary>
public class XMLHelper
{
public XMLHelper()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region XML文档节点查询和读取
/// <summary>
/// 选择匹配XPath表达式的第一个节点XmlNode.
/// </summary>
/// <param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
/// <param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
/// <returns>返回XmlNode</returns>
public static XmlNode GetXmlNodeByXpath(string xmlFileName, string xpath)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
......
总记录数:815; 总页数:136; 每页6 条; 首页 上一页 [101] [102] [103] [104] 105 [106] [107] [108] [109] [110]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号