易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript跨浏览器创建XML对象


var
 
xmlDoc
 
=
 
null
;
function
 
parseXML
(
xmlUrl
)
{
  try
 
{
    //IE
    xmlDoc
 
=
 
new
 
ActiveXObject
(
"Microsoft.XMLDOM"
);
    xmlDoc
.
async
 
=
 
false
;
    xmlDoc
.
load
(
xmlUrl
);
  }
catch
(
e
)
  {
    try
{
    //
Firefox

Mozilla

Opera

etc
.
    xmlDoc
 
=
 
document
.
implementation
.
createDocument
(
""
,
""
,
null
);
    xmlDoc
.
async
 
=
 
false
;
    xmlDoc
.
load
(
xmlUrl
);
    }
catch
(
e
)
    {
      try
{
        //
google
,
Safari
       
var
 
xmlhttp
 
=
 
new
 
window
.
XMLHttpRequest
();
        xmlhttp
.
open
(
"GET"
,
xmlUrl
,
false
);
        xmlhttp
.
send
(
null
);
        xmlDoc
 
=
 
xmlhttp
.
responseXML
.
documentElement
;
      }
catch
(
e
){
alert
(
e
.
message
+
"  EROR"
);
return
;}
    }
  }
}


相关文档:

[翻译]High Performance JavaScript(009)

第三章  DOM Scripting  DOM编程
    DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......

IsolatedStorageFile 本地数据缓存 xml dataset 读写

IsolatedStorageFile:包含文件和数据的独立存储区
dataset数据存储到本地xml文档,代码处理如下
public static void WriteDataToXML(DataSet dataset, string dataname)
{
try
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); / ......

在XML中定义菜单

和Android UI layout一样,我们也可以在XML中定义应用程序的菜单。通过在菜单的onCreateOptionsMenu方法中膨胀菜单layout。这样做会使我们的程序代码简单多了,而且尽可能的将更多的界面设计部分放到XML,便于浏览。
 
1. 在工程的/res/文件夹下创建menu文件夹,用来保存你为应用程序定义的菜单XML文件。
在菜单XML ......

Linq to XML customize distinct function

Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
......

DataSet XMl DateTable 互转

/// <summary>
/// DataTable-------------------->XML --String
/// </summary>
public static String ToXmlString(DataTable dt)
{
StringWriter tr = new StringWriter();
try
{
dt.WriteXml(tr); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号