如何在C#中从XML获取属性

时间:2018-07-16 13:10:20

标签: c# xml

我正在获取可以访问约会nbr的输出xml格式,但是我无法使用eqid。如何获取slot-start,slot-end,eqid。

 > <appointment-nbr>494</appointment-nbr> <slot
 > slot-start="2018-07-16T12:31:00" slot-end="2018-07-16T13:00:00" />
 > <appointment requires-xray="false" /> <container eqid="ASWU2705080" />

这是我的代码

foreach (XmlNode node in appointmentsresponce){
XmlElement flightEle = (XmlElement)node;
XmlNodeList appointmentnbr = flightEle.GetElementsByTagName("appointment-nbr");
XmlNodeList containerNodeList = flightEle.GetElementsByTagName("container");
}

2 个答案:

答案 0 :(得分:0)

尝试(由于您没有发布完整的数据,我有点猜测):

const fs = require('fs');

const writeStream = fs.createWriteStream('file.txt');

const pathName = writeStream.path;

let array = ['1','2','3','4','5','6','7'];

// write each value of the array on the file breaking line
array.forEach(value => writeStream.write(`${value}\n`));

// the finish event is emitted when all data has been flushed from the stream
writeStream.on('finish', () => {
   console.log(`wrote all the array data to file ${pathName}`);
});

// handle the errors on the write process
writeStream.on('error', (err) => {
    console.error(`There is an error writing the file ${pathName} => ${err}`)
});

// close the stream
writeStream.end();

答案 1 :(得分:0)

您的data-bind = "value : param___isUsed" // Undefined...??? 上的简单调用GetAttribute("AttributeName")

所以:

XmlElement