当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextWriter.WriteValue方法代码示例

本文整理汇总了C#中XmlTextWriter.WriteValue方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteValue方法的具体用法?C# XmlTextWriter.WriteValue怎么用?C# XmlTextWriter.WriteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlTextWriter的用法示例。


在下文中一共展示了XmlTextWriter.WriteValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteGestureLog

            public void WriteGestureLog(Dictionary<String, Point3D> gestureDict, string timeStamp)
            {
                using (StringWriter sw = new StringWriter(_sBuilder))
                {
                    using (XmlWriter xmlWriter = new XmlTextWriter(sw))
                    {
                        //START MOVEMENT
                        xmlWriter.WriteStartElement("mov");
                        xmlWriter.WriteStartAttribute("time_stamp");
                        xmlWriter.WriteValue(timeStamp);
                        xmlWriter.WriteEndAttribute();
                        //PRINT ALL JOINTS
                        foreach (var point in gestureDict)
                        {
                            xmlWriter.WriteStartElement(point.Key);//START JOINT
                            xmlWriter.WriteStartElement("x");
                            xmlWriter.WriteValue(point.Value.X);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Y");
                            xmlWriter.WriteValue(point.Value.Y);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Z");
                            xmlWriter.WriteValue(point.Value.Z);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndElement();//END JOINT
                        }
                        xmlWriter.WriteEndElement();//END MOV
                    }

                }
                WriteToXMLLogFile();
            }
开发者ID:saflogar,项目名称:GestureTrainingInterface,代码行数:32,代码来源:XMLLoggerSingleton.cs

示例2: AddRSSItem

 public XmlTextWriter AddRSSItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, string datetime)
 {
     string itemname = System.IO.Path.GetFileName(sItemLink);
       writer.WriteStartElement("item");
            writer.WriteElementString("title",       sItemTitle);
            writer.WriteElementString("link",        "http://www.weavver.com/?redirect=" + itemname);
            writer.WriteElementString("description", "");
            writer.WriteElementString("author",      "Jane Doe");
            writer.WriteElementString("contact",     "tel://17148531212");
            writer.WriteElementString("pubDate",     datetime);
            writer.WriteElementString("tags",        "Unheard,Work");
            writer.WriteStartElement("enclosure");
                 writer.WriteAttributeString("url",                 "http://www.weavver.com/messages/" + itemname);
                 writer.WriteAttributeString("length",              "572345");
                 writer.WriteAttributeString("type",                "audio/wav");
                 writer.WriteStartElement("transcription");
                      writer.WriteAttributeString("confidence", "1.0");
                      writer.WriteValue("THIS IS THE TRANSCRIPTION.");
                 writer.WriteEndElement();
            writer.WriteEndElement();
       writer.WriteEndElement();
       return writer;
 }
开发者ID:weavver,项目名称:weavver,代码行数:23,代码来源:Podcast.aspx.cs

示例3: SqlDataReaderToXml

    private static void SqlDataReaderToXml(
    SqlDataReader AReader,
    //DataTable     ADataTable,
    XmlTextWriter AWriter,
    Boolean       ASkipNameColumn,
    String        ARowTag,
    TRowSetMap    AMap
  )
    {
        const String ROW_TAG      = "ROW";
        const String METADATA_TAG = "METADATA";
        const String FIELD_TAG    = "FIELD";
        const String NONAME_FIELD_PREFIX = "FIELD";

        int
          i,
          start_field_index   = ASkipNameColumn ? 1 : 0,
          empty_name_field_no = 1;
        String FieldName;

        DataTable LDataTable = AReader.GetSchemaTable();

        List<TFieldAlias> LFields = new List<TFieldAlias>();
        TFieldAlias LField;
        int FieldCount = AReader.FieldCount;

        if(AMap.Fields.Length > 0)
        {
          foreach (String FieldMap in AMap.Fields.Split(new char[] {','}))
          {
        i = FieldMap.IndexOf('=');
        if(i >= 0)
        {
          LField.Name = FieldMap.Substring(0, i);
          FieldName   = FieldMap.Substring(i + 1);
        }
        else
        {
          LField.Name = FieldMap;
          FieldName   = FieldMap;
        }
        for(i = start_field_index; i < FieldCount; i++)
        {
          if(FieldName.Equals(AReader.GetName(i), StringComparison.InvariantCultureIgnoreCase))
            break;
        }
        if((i < 0) || (i >= FieldCount))
          throw new SystemException("RowSet Field = [" + FieldName + "] not found.");
        // LField.Name = XmlConvert.EncodeLocalName(LField.Name);
        LField.FieldIndex = i;
        LFields.Add(LField);

        //AWriter.WriteStartAttribute(LField.Name);
        //AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[i]));
          }
        }
        else
        {
          for(LField.FieldIndex = start_field_index; LField.FieldIndex < FieldCount; LField.FieldIndex++)
          {
        FieldName = AReader.GetName(LField.FieldIndex);
        if(FieldName.Length == 0)
          FieldName = NONAME_FIELD_PREFIX + (empty_name_field_no++).ToString();
        LField.Name = FieldName;
        //LField.Name = XmlConvert.EncodeLocalName(FieldName);
        LFields.Add(LField);

        //AWriter.WriteStartAttribute(LField.Name);
        //AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[LField.FieldIndex]));
          }
        }

        AWriter.WriteStartElement(METADATA_TAG);
        for (i = 0; i < LFields.Count; i++)
        {
          AWriter.WriteStartElement(FIELD_TAG);
        AWriter.WriteStartAttribute(ATTRIBUTE_INDEX);
        AWriter.WriteValue(i + 1);
        AWriter.WriteStartAttribute(ATTRIBUTE_NAME);
        AWriter.WriteValue(LFields[i].Name);
        AWriter.WriteStartAttribute(ATTRIBUTE_TYPE);
        AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[LFields[i].FieldIndex]));
          AWriter.WriteEndElement();
        }
        AWriter.WriteEndElement();

        object Value;
        while (AReader.Read())
        {
          AWriter.WriteStartElement(ARowTag ?? ROW_TAG);

          for (i = 0; i < LFields.Count; i++)
          {
        Value = AReader.GetValue(LFields[i].FieldIndex);
        if (Value != DBNull.Value) // NULL пропускаем
        {
          AWriter.WriteStartAttribute(XmlConvert.EncodeLocalName(LFields[i].Name));
          try
          {
            AWriter.WriteValue(Value);
//.........这里部分代码省略.........
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:101,代码来源:Sql.UDP.GetResult.cs

示例4: ExecuteToXML

    public static void ExecuteToXML(
    String AQuery,
    String AResultSets,
out SqlXml AXml,
    String ARowsetNamePrefix  = null,
    String ARootTag           = null,
    String ARowsetTag         = null,
    String ARowTag            = null
  )
    {
        const String ROWSET_TAG = "ROWSET";

        if (String.IsNullOrEmpty(AQuery))
          throw new ArgumentNullException(PARAM_QUERY);

        if (String.IsNullOrEmpty(ARowsetTag))
          ARowsetTag = ROWSET_TAG;

        List<TRowSetMap> LMaps;
        TRowSetMap LMap;

        if (AResultSets == null)
          LMaps = new List<TRowSetMap>();
        else
          LMaps = ExtractRowSetMaps(AResultSets);

        LMap.Index  = -1;
        LMap.Name   = null;
        LMap.Fields = "";

        using (SqlConnection LSqlConnection = new SqlConnection(ContextConnection))
        {
          LSqlConnection.Open();

          using (SqlCommand LSqlCommand = new SqlCommand(AQuery, LSqlConnection))
          using (SqlDataReader LReader = LSqlCommand.ExecuteReader())
          {
        int LRowsetNo = 0;
        int i = 0;

        // !!! Нельзя делать ms.Dispose, потому что данные тянет из ms уже в T-SQL-коде ("извне" этой процедуры )
        MemoryStream  LMemoryStream = new MemoryStream();
        XmlTextWriter LXml          = new XmlTextWriter(LMemoryStream, Encoding.Unicode);

        if(!String.IsNullOrEmpty(ARootTag))
          LXml.WriteStartElement(ARootTag);
        else
          AXml = SqlXml.Null;

        do
        {
          if(LReader.IsClosed) break;

          String LRowsetName = null;
          //DataTable LDataTable = LReader.GetSchemaTable();
          if (!String.IsNullOrEmpty(ARowsetNamePrefix))
          {
            String LColumn0Name = LReader.GetName(0);
            //SqlContext.Pipe.Send("LColumn0Name = " + LColumn0Name);

            if (!String.IsNullOrWhiteSpace(LColumn0Name) && LColumn0Name.StartsWith(ARowsetNamePrefix, StringComparison.InvariantCultureIgnoreCase))
              LRowsetName = LColumn0Name.Substring(ARowsetNamePrefix.Length);
          }

          if (AResultSets == null)
            i = ++LRowsetNo;
          else
          {
            LRowsetNo++;
            i = LMaps.FindIndex
                (
                  (
                    delegate(TRowSetMap AMap)
                    {
                      return (AMap.Index > 0 && AMap.Index == LRowsetNo) || (AMap.Index == 0 && LRowsetName != null && AMap.Name == LRowsetName);
                    }
                  )
                );

            if (i < 0) continue;
            LMap = LMaps[i++];
          }

          LXml.WriteStartElement(LRowsetName ?? ARowsetTag);

          LXml.WriteStartAttribute(ATTRIBUTE_INDEX);
          LXml.WriteValue(i.ToString());

          //if(LRowsetName != null)
          //{
          //  LXml.WriteStartAttribute(ATTRIBUTE_NAME);
          //  LXml.WriteValue(LRowsetName);
          //}

          SqlDataReaderToXml(LReader, LXml, (LRowsetName != null), ARowTag, LMap);
          LXml.WriteEndElement();

        } while (LReader.NextResult());

        if(!String.IsNullOrEmpty(ARootTag))
//.........这里部分代码省略.........
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:101,代码来源:Sql.UDP.GetResult.cs

示例5: SaveMap

    /// <summary>
    /// Save the map to file.
    /// </summary>
    /// <param name="filename">
    /// A <see cref="System.String"/>
    /// </param>
    private void SaveMap(string filename)
    {
        //XML file
        string xmlFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".xml");
        //Tile data file
        //string tdFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".td");

        Log.Write("Saving current map to XML " + xmlFile);

        XmlWriter xmlWriter = new XmlTextWriter(xmlFile, new System.Text.UTF8Encoding());

        xmlWriter.WriteStartDocument();
        xmlWriter.WriteWhitespace("\r\n");
        xmlWriter.WriteStartElement("map");
        xmlWriter.WriteStartAttribute("id");
        xmlWriter.WriteValue(model.MapID);
        xmlWriter.WriteEndAttribute();

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("geometry");

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("width");
        xmlWriter.WriteValue(model.TileMap.Width);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("height");
        xmlWriter.WriteValue(model.TileMap.Height);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("layers");
        xmlWriter.WriteValue(model.TileMap.Layers);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("tilesize");
        xmlWriter.WriteValue(model.TileMap.Tilesize);
        xmlWriter.WriteEndElement();

        //Offsets
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("xoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetX);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("yoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetY);
        xmlWriter.WriteEndElement();

        //Geometry end
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Tileset
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("tileset");
        {

            bool foundTileset = false;
            foreach (string tsName in model.ResourceManager.Tilesets)
            {
                Tileset ts = model.ResourceManager.GetTileset(tsName);
                if (ts == model.CurrentTileset)
                {
                    xmlWriter.WriteValue(tsName);
                    foundTileset = true;
                    break;
                }
            }
            if (!foundTileset)
            {
                throw new NotFoundException("Tileset was not found in resource manager. This should not happen! What did you do?");
            }
        }

        xmlWriter.WriteEndElement();

        //Background
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("background");
        xmlWriter.WriteValue(model.Background);
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Extra properties
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("properties");
        foreach (KeyValuePair<string, string> o in model.ExtraProperties)
//.........这里部分代码省略.........
开发者ID:hallgeirl,项目名称:Hiage,代码行数:101,代码来源:MainWindow.cs

示例6: WriteValue

 void WriteValue(XmlTextWriter textWriter, string key, float value)
 {
     textWriter.WriteStartElement(key, "");
     textWriter.WriteValue(value);
     textWriter.WriteEndElement();
 }
开发者ID:corybarr,项目名称:PlanetariumSwarm,代码行数:6,代码来源:SaveSettings.cs

示例7: WriteProjectFile

        void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module)
        {
            const string ns = "http://schemas.microsoft.com/developer/msbuild/2003";
            string platformName = GetPlatformName(module);
            Guid guid = Guid.NewGuid();
            using (XmlTextWriter w = new XmlTextWriter(writer))
            {
                w.Formatting = Formatting.Indented;
                w.WriteStartDocument();
                w.WriteStartElement("Project", ns);
                w.WriteAttributeString("ToolsVersion", "4.0");
                w.WriteAttributeString("DefaultTargets", "Build");

                w.WriteStartElement("PropertyGroup");
                w.WriteElementString("ProjectGuid", guid.ToString("B").ToUpperInvariant());

                w.WriteStartElement("Configuration");
                w.WriteAttributeString("Condition", " '$(Configuration)' == '' ");
                w.WriteValue("Debug");
                w.WriteEndElement(); // </Configuration>

                w.WriteStartElement("Platform");
                w.WriteAttributeString("Condition", " '$(Platform)' == '' ");
                w.WriteValue(platformName);
                w.WriteEndElement(); // </Platform>

                switch (module.Kind)
                {
                    case ModuleKind.Windows:
                        w.WriteElementString("OutputType", "WinExe");
                        break;
                    case ModuleKind.Console:
                        w.WriteElementString("OutputType", "Exe");
                        break;
                    default:
                        w.WriteElementString("OutputType", "Library");
                        break;
                }

                w.WriteElementString("AssemblyName", module.Assembly.Name.Name);
                bool useTargetFrameworkAttribute = false;
                var targetFrameworkAttribute = module.Assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "System.Runtime.Versioning.TargetFrameworkAttribute");
                if (targetFrameworkAttribute != null && targetFrameworkAttribute.ConstructorArguments.Any())
                {
                    string frameworkName = (string)targetFrameworkAttribute.ConstructorArguments[0].Value;
                    string[] frameworkParts = frameworkName.Split(',');
                    string frameworkVersion = frameworkParts.FirstOrDefault(a => a.StartsWith("Version="));
                    if (frameworkVersion != null)
                    {
                        w.WriteElementString("TargetFrameworkVersion", frameworkVersion.Substring("Version=".Length));
                        useTargetFrameworkAttribute = true;
                    }
                    string frameworkProfile = frameworkParts.FirstOrDefault(a => a.StartsWith("Profile="));
                    if (frameworkProfile != null)
                        w.WriteElementString("TargetFrameworkProfile", frameworkProfile.Substring("Profile=".Length));
                }
                if (!useTargetFrameworkAttribute)
                {
                    switch (module.Runtime)
                    {
                        case TargetRuntime.Net_1_0:
                            w.WriteElementString("TargetFrameworkVersion", "v1.0");
                            break;
                        case TargetRuntime.Net_1_1:
                            w.WriteElementString("TargetFrameworkVersion", "v1.1");
                            break;
                        case TargetRuntime.Net_2_0:
                            w.WriteElementString("TargetFrameworkVersion", "v2.0");
                            // TODO: Detect when .NET 3.0/3.5 is required
                            break;
                        default:
                            w.WriteElementString("TargetFrameworkVersion", "v4.0");
                            break;
                    }
                }
                w.WriteElementString("WarningLevel", "4");

                w.WriteEndElement(); // </PropertyGroup>

                w.WriteStartElement("PropertyGroup"); // platform-specific
                w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' ");
                w.WriteElementString("PlatformTarget", platformName);
                w.WriteEndElement(); // </PropertyGroup> (platform-specific)

                w.WriteStartElement("PropertyGroup"); // Debug
                w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' ");
                w.WriteElementString("OutputPath", "bin\\Debug\\");
                w.WriteElementString("DebugSymbols", "true");
                w.WriteElementString("DebugType", "full");
                w.WriteElementString("Optimize", "false");
                w.WriteEndElement(); // </PropertyGroup> (Debug)

                w.WriteStartElement("PropertyGroup"); // Release
                w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' ");
                w.WriteElementString("OutputPath", "bin\\Release\\");
                w.WriteElementString("DebugSymbols", "true");
                w.WriteElementString("DebugType", "pdbonly");
                w.WriteElementString("Optimize", "true");
                w.WriteEndElement(); // </PropertyGroup> (Release)

//.........这里部分代码省略.........
开发者ID:HearthSim,项目名称:extract-scripts,代码行数:101,代码来源:decompile.cs


注:本文中的XmlTextWriter.WriteValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。