|
i am final year student doing a project in XML and just want solution to the querie posted by you
kindly respond
remya
|
|
|
|
|
Hi
I developed an application using VB.NET with VS 2005.
I add xml comments as needed to every method/class/members etc.
Now i want to create an help file based on this comments.
I found a convertion tool for C# (NDoc) but not for VB.NET.
I need a simple tool to create a MSDN like help file based on VB.NET xml coments.
Tnx
-- modified at 6:59 Sunday 12th March, 2006
|
|
|
|
|
Hi all,
I'm trying to read a file wuth C#. The file contains the following:
<?xml version="1.0" encoding="utf-8" ?>
<voice_config>
<voice_type>Microsoft Mary</voice_type>
<voice_volume>100</voice_volume>
<voice_rate>0</voice_rate>
</voice_config>
and the code to read is:
voice_reader.Read();
voice_reader.ReadStartElement("voice_config");
voice_reader.ReadStartElement("voice_type");
m_voice = voice_reader.ReadString();
voice_reader.ReadEndElement();
voice_reader.ReadStartElement("voice_volume");
m_volume = voice_reader.ReadContentAsInt();
voice_reader.ReadEndElement();
voice_reader.ReadStartElement("voice_rate");
m_rate = voice_reader.ReadContentAsInt();
voice_reader.ReadEndElement();
voice_reader.ReadEndElement();
I'm getting the following exception thrown:
Exception : Unexpected XML Declaration. The XML Declaration should be the first node in the document, and no whitespace characters are allowed to appear before it, Line 1 position 100
|
|
|
|
|
// You are not advancing through the document, Example:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace XmlRdr
{
class Program
{
static void Main(string[] args)
{
XmlReader voice_reader = null;
try
{
voice_reader = XmlReader.Create(@"C:\voice_config.xml");
while (voice_reader.Read())
{
if (voice_reader.NodeType == XmlNodeType.Element)
{
switch (voice_reader.Name)
{
case "voice_config":
break;
case "voice_type":
Console.WriteLine(voice_reader.ReadString());
break;
case "voice_volume":
Console.WriteLine(voice_reader.ReadString());
break;
case "voice_rate":
Console.WriteLine(voice_reader.ReadString());
break;
default:
break;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (voice_reader != null && voice_reader.ReadState != ReadState.Closed)
{
voice_reader.Close();
}
}
}
}
}
|
|
|
|
|
Got it now. Knew it would be simple.
|
|
|
|
|
Hi,
I'm designing a framework for an enterprise application.
I have done this earlier but I used to define model (properties, methods, events…) inside framework itself.
Programmer writes codes based on the model defined in framework, in other words interface that is created inside framework later implemented by the programmer.
Now I would like to isolate model definition from framework and define the model in a separate XML file so that framework will extract model definition from XML file dynamically.
How do I achieve this ?
Advance Thanks !
Regards,
aB
|
|
|
|
|
Using "Reflection" might be an option.
|
|
|
|
|
Hi to everybody,
I need some help to convert a XML DataSet to an Excel file. I actually using this code:
Private Sub TransformXML(ByVal xmlDoc As XmlDataDocument, _
ByVal strXSLPath As String, _
ByVal strSavePath As String)
Dim xt As New XslCompiledTransform
Dim tw As XmlTextWriter
tw = New XmlTextWriter(strSavePath, System.Text.Encoding.UTF8)
tw.Formatting = Formatting.Indented
tw.Indentation = 3
tw.WriteStartDocument()
xt.Load(My.Application.Info.DirectoryPath & strXSLPath)
xt.Transform(xmlDoc, Nothing, tw)
tw.Close()
End Sub
The XSLT follow here :
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns ="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" >
<xsl:template match="/">
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns ="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:apply-templates/>
</Workbook>
</xsl:template>
<xsl:template match="/*">
<Worksheet>
<xsl:attribute name="ss:Name">
<xsl:value-of select="local-name(/*/*)"/>
</xsl:attribute>
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<xsl:for-each select="*[position() = 1]/*">
<Cell>
<Data ss:Type="String">
<xsl:value-of select="local-name()"/>
</Data>
</Cell>
</xsl:for-each>
</Row>
<xsl:apply-templates/>
</Table>
</Worksheet>
</xsl:template>
<xsl:template match="/*/*">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>
<xsl:template match="/*/*/*">
<Cell>
<Data ss:Type="String">
<xsl:value-of select="."/>
</Data>
</Cell>
</xsl:template>
</xsl:stylesheet>
The problem is that the XSLT must be generic because the DataSet it's always different. I would like to retrieve the datatype from the DataSet schema and create the Excel file properly. The XSLT attached perform only a simple transformation.
Can anyone help me with XSLT and kindly provide a better implementation?
Thanks in advance to anyone will replay
|
|
|
|
|
Dim ds4xmlcsv As New DataSet
Dim export As New ConvertXMLtoCSV
Dim f1 As File
Dim fullpath As String
Try
ds4xmlcsv.ReadXml(cc)
export.Export(ds4xmlcsv, True)
ds4xmlcsv.Clear()
If MsgBox("The Transfer is Complete", MsgBoxStyle.MsgBoxSetForeground.OKOnly, "Thank You") = MsgBoxResult.OK Then
btntrs2csv.Enabled = False
Exit Sub
End If
Catch errormsg As Exception
MsgBox(errormsg.Message + sessiontime.Now)
End Try
Public Function Export(ByVal ds As DataSet, ByVal exportcolumnheadings As Boolean) As String
'Dim ts11 As String
'ts11 = txtinputxmltext
'TextBox1.Text = ""
Dim ts As String
'Dim rep As String
Dim ts22 As String
ts22 = "XML2CSV.csv"
ts = Path.GetFileName(txtsavetext)
fname = txtsavetext.Replace(ts, ts22)
Dim header As String
Dim body As String
Dim record As String
Dim f As file
Dim ii As Integer
'Dim cc As String
'cc = "C:\bin\XMLInput.csv"
'f.CreateText(cc)
If f.Exists(fname) Then
f.Delete(fname)
End If
Dim writer As StreamWriter = New StreamWriter(fname)
If exportcolumnheadings Then
For Each col As DataColumn In ds.Tables(0).Columns
header = header & Chr(34) & col.ColumnName & Chr(34) & ","
Next
header = header.Substring(0, header.Length - 1)
writer.WriteLine(header)
writer.Close()
End If
For Each row As DataRow In ds.Tables(0).Rows
Dim arr() As Object = row.ItemArray()
For i As Integer = 0 To arr.Length - 1
If arr(i).ToString().IndexOf(",") > 0 Then
record = record & Chr(34) & arr(i).ToString() & Chr(34) & ","
Else
record = record & arr(i).ToString() & ","
'cc.Concat(header, record)
End If
Next
'If ii = 0 Then
' Dim writer2 As StreamWriter = New StreamWriter(cc, False)
' writer2.WriteLine(record)
' writer2.Close()
' ii = 1
'Else
Dim writer2 As StreamWriter = New StreamWriter(fname, True)
writer2.WriteLine(record)
writer2.Close()
'End If
body = body & record.Substring(0, record.Length - 1) & vbCrLf
record = ""
Next
If exportcolumnheadings Then
Return header & vbCrLf & body
'writer.WriteLine(header & vbCrLf & body)
'writer.Close()
Else
Return body
'writer.WriteLine(body)
End If
End Function
bharath.s
-- modified at 5:52 Friday 17th March, 2006
|
|
|
|
|
Thanks for your reply, but I want to convert my XML to XLS using XSLT.
Here an example of what I want to have!
http://support.microsoft.com/?kbid=319180
The code posted already work, I need only a better implementation of the stylesheet...
Thanks again
|
|
|
|
|
Im new to using Xml with C#. I have been hacking around at one section for a day now and can't get it to work at all. Rather than confuse you with my shambles code, I will jsut explain the concept. Im also slightly confussed, or misslead with my understanding of the type deffinitions, and their methods for subtrees.
<code>
XML...
<Root>
<MajorKey att="MAJattribute1">
<MinorKey att="MINattribute1">
<Value>value1</Value>
</MinorKey>
<MinorKey att="MINattribute2">
<Value>value2</value>
</MinorKey>
</MajorKey>
<MajorKey att="MAJattribute2">
<MinorKey att="MINattribute3">
<Value>value3</Value>
</MinorKey>
<MinorKey att="MINattribute4">
<Value>value4</value>
</MinorKey>
</MajorKey>
</Root>
</code>
Im having trouble getting it to create a nodelist to children underneath a node based on it's att (attribute) value. Also, I want to extract that attribute value into a string so "MAJattribute1" would gointo a string inside the loop for that node treversal.
Any help, or suggestions.
I have spent hours and hours reading, and cant seem to find anything to pinpoint this...only ever creating attributes indide a single node, not looping through based on the attribute value.
IM GETTING STRESSED
Regards
njc
|
|
|
|
|
I Want Voip Concept and avilable web sites
|
|
|
|
|
Hi evry body
---------------
I want an Article about XMl
that this Article explain what is the XML and what we can do with XML
I want a little history of XML and some informations about XML WebService
---------------
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
http://www.topxml.com/php_xml_dom/default.asp
|
|
|
|
|
thanks WhiteSky
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
http://www.w3schools.com
for beginner in XML
"I find that the harder I work, the more luck I seem to have."
|
|
|
|
|
How to add Images into my <question> or <answer>? My code is as below.
-----------------------------------------------------------------------------
<quiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="quiz.xsd">
<mchoice>
<question>When you create a new document, it always displays behind the Toolbox. Which of the following actions will ensure it always opens flush with the Toolbox?</question>
<answer>Using the keyboard shortcut key Ctrl+N [Cmd+N] to always create a new document</answer>
<answer>Making sure the Options bar is not parked flush with the top of the screen; allowing a gap of a few pixels in between</answer>
<answer>Holding down the Alt [Opt] key as you click the OK button in the New dialog</answer>
<answer correct="yes">Moving the Toolbox a few pixels away from the edge of the screen</answer>
</mchoice>
|
|
|
|
|
Yeah u found the solution use this line of code
<![ CDATA [[img]../pic.jpg[/img]]]>
|
|
|
|
|
Hi,
VS 2005 / C#
Simple situation: A DataTable with some columns and rows added. But when using the WriteXML method to create an XML file from this table it gives me the following output:
<?xml version="1.0" encoding="utf-8"?>
<DocumentElement>
<Batch_Table>
<Height>18</Height>
<Width>75</Width>
<Program>1</Program>
<Length1Min>18</Length1Min>
<Length1Max>60</Length1Max>
<Price1>1000</Price1>
</Batch_Table>
<Batch_Table>
<Height>25</Height>
<Width>125</Width>
<Program>2</Program>
<Length1Min>12</Length1Min>
<Length1Max>40</Length1Max>
<Price1>1200</Price1>
<Length2Min>40</Length2Min>
<Length2Max>60</Length2Max>
<Price2>1300</Price2>
</Batch_Table>
...and so on. The problem is that each row/record of the table is named as the TABLE (which is called "Batch_Table"). This is wrong! How can I fix this?
Thanks.
/Magnus
|
|
|
|
|
how to get microsoft.xmldom?
I dont find this activex
can you help me
thanks
|
|
|
|
|
WhiteSky wrote: how to get microsoft.xmldom?
this is the syntax.....
obj = new ActiveXObject('Microsoft.XMLDOM');
or
obj = new ActiveXObject('MSXML2.DOMDocument.4.0');
use either of the two in ur scripts
sathy
|
|
|
|
|
I need to 'Microsoft.XMLDOM'
|
|
|
|
|
Hi,
I am having an XML file which has two elments id & StartDate, Iam using Visual C# > XMLTextReader Object "reader" to read this file, if the nodetype is text and the elementname is startdate then write the startdate by converting it. If you see the below code hope every thing gets clear
Insted of getting the value I want to search if the XmlNodeType is text then I want to get the datatype (i.e. date or string or int32 etc.) of the element insted of the value
System.IO.Stream objStream = new System.IO.MemoryStream();
DataSet objDs = new DataSet();
objDs = getData();
XmlTextReader reader = new XmlTextReader(objDs.GetXml(), XmlNodeType.Element, null) ;
Response.ContentType = "text/xml";
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
writer.Indentation = 4;
writer.WriteStartDocument();
string elementName = "";
while(reader.Read())
{
switch(reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Name);
elementName = reader.Name;
break;
// In the below case I have a problem I want to get the datatype of the node insted of the data
case XmlNodeType.Text:
if(elementName == "StartDate")
writer.WriteString(XmlConvert.ToDateTime(reader.Value).ToString());
else
writer.WriteString(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteEndElement();
break;
}
|
|
|
|
|
The type of the element is defined in the schemas, there is no way to get this information from the xml document alone.
Denevers
|
|
|
|
|
hi all,i'm creating a mobile appliction with ms vs2005 release edition, im using a webservice from www.webservicex.com and i get the exception with the details :
Status :System.Net.WebExceptionStatus.ConnectFailure
System.Net.WebException was unhandled
Message="Could not establish connection to network."
StackTrace:
at System.Net.HttpWebRequest.finishGetResponse()
at System.Net.HttpWebRequest.GetResponse()
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse()
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse()
at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke()
at DeviceApplication2.net.webservicex.www.lengthUnit.ChangeLengthUnit()
at DeviceApplication2.Form1.button1_Click()
at System.Windows.Forms.Control.onclick()
at System.Windows.Forms.Button.onclick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at DeviceApplication2.Program.Main()
&here's my code:
private void button1_Click(object sender, EventArgs e)
{
net.webservicex.www.lengthUnit l = new
DeviceApplication2.net.webservicex.www.lengthUnit();
double x = l.ChangeLengthUnit(120, DeviceApplication2.net.webservicex.www.Lengths.Feet, DeviceApplication2.net.webservicex.www.Lengths.Meters);
MessageBox.Show(x.ToString());
}
please tell me where is the error (i'm deploying it using the device emulator and the active sync program)
|
|
|
|