日期:2014-05-16  浏览次数:20381 次

如何读取xml的值

XML文件如下:
<?xml version="1.0" encoding="utf-8"?>
<parent>
  <title>wwwwww</title>
  <author>admin</author>
  <contentall>
    <vc1>1</vc1>
    <vc2>2</vc2>
  </contentall>
</parent>

使用js,我如何读取contentall标签里面的vc1,vc2的值了?
xml encoding js

------解决方案--------------------
function impFlow(){
var form = new Ext.form.FormPanel({
     baseCls : 'x-plain',
     labelWidth : 70,
     fileUpload : true,
     defaultType : 'textfield',
     items : [{
        xtype : 'textfield',
        fieldLabel : '流程文件名',
        name : 'xmlFile',
        id : 'xmlFile',
        inputType : 'file',
        blankText : '文件不能为空。',
        anchor : '100%'
       }]
});
 
var win = new Ext.Window({
     title : '请选择xml文件',
     width : 400,
     height : 110,
     minWidth : 300,
     minHeight : 100,
     layout : 'fit',
     plain : true,
     bodyStyle : 'padding:5px;',
     buttonAlign : 'center',
     items : form,
     buttons : [{
      text : '打开',
      handler : function() {
       if (form.form.isValid()) {
       if(Ext.getCmp('xmlFile').getValue() == ''){
       Ext.Msg.alert('错误','请选择你要读取的文件');
       return;
       }
       xmlPath = getPath(document.getElementById('xmlFile'));
       var arr = xmlPath.split('.');
       if(arr[arr.length-1] == 'xml'){
       testProcess = loadXML(xmlPath);
       XmlToProcess(testProcess);
       win.close();
       }else{
       Ext.Msg.alert('错误','您选择的文件不是xml文件');
       }
       }
       }
     }, {
      text : '关闭',
      handler : function() {
       win.close();
&nbs