C# 将xml中二进制文件 转化为视频 以及 根据节点读取节点值
/// <summary> /// 将xml转化为文件 /// </summary> /// <param name="path"></param> /// <param name="mediapath"></param> public void ReadXmlPicture(string path,string mediapath) { try { int readByte = 0; int bytesToRead = 1044; XmlTextReader xmlTxtRd = new XmlTextReader(path); FileStream fs = new FileStream(mediapath, FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); byte[] base64buffer = new byte[bytesToRead]; while (xmlTxtRd.Read()) { if (xmlTxtRd.NodeType == XmlNodeType.Element && xmlTxtRd.Name == "content") { do { readByte = xmlTxtRd.ReadBase64(base64buffer, 0, bytesToRead); bw.Write(base64buffer, 0, readByte); } while (bytesToRead <= readByte); } } bw.Flush(); bw.Close(); fs.Close(); xmlTxtRd.Close(); } catch (Exception ex) { WritetoLog(ex.ToString()); } } /// <summary> /// 根据节点获得节点值 /// </summary> /// <param name="path"></param> /// <param name="nodeName"></param> /// <returns></returns> public static string GetNodeInfoByNodeName(string path, string nodeName) { string XmlString = ""; XmlDocument xml = new XmlDocument(); xml.Load(path); System.Xml.XmlElement root = xml.DocumentElement; System.Xml.XmlNode node = root.SelectSingleNode("//" + nodeName); if (node != null) { XmlString = node.InnerText; } return XmlString; }