Click here to Skip to main content
15,912,977 members
Home / Discussions / XML / XSL
   

XML / XSL

 
AnswerRe: Print XSLT? I want to print XSLT(HTML and PDF) file. Pin
adatapost26-May-09 1:38
adatapost26-May-09 1:38 
AnswerRe: Print XSLT? Pin
notarry27-May-09 16:06
notarry27-May-09 16:06 
QuestionReading XML Pin
M_Aurelius23-May-09 22:20
M_Aurelius23-May-09 22:20 
AnswerRe: Reading XML Pin
harold aptroot23-May-09 23:46
harold aptroot23-May-09 23:46 
QuestionHelp for newbie Pin
Konstantin Yazvinski21-May-09 12:28
Konstantin Yazvinski21-May-09 12:28 
AnswerRe: Help for newbie Pin
led mike22-May-09 4:31
led mike22-May-09 4:31 
QuestionSelect XmlElement Help Pin
papy-boom21-May-09 3:27
papy-boom21-May-09 3:27 
QuestionHow to create a tool to generate xslt to transform one xml to another? Pin
salon21-May-09 1:15
salon21-May-09 1:15 
Questionremoving unwanted empty XML elements (this one contains code in a legible form) Pin
Craig Irwin20-May-09 17:37
Craig Irwin20-May-09 17:37 
AnswerRe: removing unwanted empty XML elements (this one contains code in a legible form) [modified] Pin
brifiction24-Apr-10 18:23
brifiction24-Apr-10 18:23 
QuestionRemoving unwanted empty XML elements Pin
Craig Irwin20-May-09 17:22
Craig Irwin20-May-09 17:22 
QuestionASP.Net : Xml Version Format Pin
Vijay Jadhav, India.18-May-09 0:18
Vijay Jadhav, India.18-May-09 0:18 
AnswerRe: ASP.Net : Xml Version Format Pin
Samer Aburabie18-May-09 7:29
Samer Aburabie18-May-09 7:29 
GeneralRe: ASP.Net : Xml Version Format Pin
Vijay Jadhav, India.18-May-09 22:01
Vijay Jadhav, India.18-May-09 22:01 
AnswerRe: ASP.Net : Xml Version Format [modified] Pin
George L. Jackson19-May-09 6:20
George L. Jackson19-May-09 6:20 
GeneralRe: ASP.Net : Xml Version Format Pin
Vijay Jadhav, India.20-May-09 0:55
Vijay Jadhav, India.20-May-09 0:55 
GeneralRe: ASP.Net : Xml Version Format Pin
Vijay Jadhav, India.25-May-09 20:03
Vijay Jadhav, India.25-May-09 20:03 
QuestionASP.NET : Identify XSD on the basis of XML in Web Service [modified] Pin
Vijay Jadhav, India.18-May-09 0:11
Vijay Jadhav, India.18-May-09 0:11 
Questionhow do i delete a xml file ? Pin
YiXiang_8916-May-09 22:47
YiXiang_8916-May-09 22:47 
Questionparse out the member name value Pin
califgal13-May-09 21:22
califgal13-May-09 21:22 
AnswerRe: parse out the member name value Pin
led mike14-May-09 4:36
led mike14-May-09 4:36 
QuestionParsing XML file -exception because element node contains a space in name Pin
califgal13-May-09 16:15
califgal13-May-09 16:15 
I am trying to parse the below xml file

<myStuff>
<my Name>Tom Brown</myName>
<my Telephone>123456789</myTelephone>
<my Email>sample@testmail.com</myEmail>
<my Age>22</myAge>
<my Age>32</myAge>
<my Sex>M</mySex>
</myStuff>

with following code.

using (StreamWriter sw = new StreamWriter("result.txt", true))
{

while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
sw.Write("<" + reader.Name.ToString());
sw.Write(">");
break;
case XmlNodeType.Text: //Display the text in each element.
sw.Write(reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
sw.Write("</" + reader.Name);
sw.Write(">");
break;
}

}

but it throws an exception because the Node name contains whitespace

can anyone help me fix this issue?

->the exception message is below.

System.Xml.XmlException was unhandled
Message="'>' is an unexpected token. The expected token is '='. Line 2, position 11."
Source="System.Xml"
LineNumber=2
LinePosition=11
SourceUri="file:///C:/Users/mirapark/Documents/Visual Studio 2008/Projects/simpleXMLparser/SimpleXMLParser/bin/Debug/sampleXML.xml"
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at WindowsFormsApplication1.Form1.xmlParse() in C:\Users\mirapark\Documents\Visual Studio 2008\Projects\IntellisenseFileTesting\IntellisenseFileTesting\Form1.cs:line 85
at WindowsFormsApplication1.Form1.button1_Click_1(Object sender, EventArgs e) in C:\Users\mirapark\Documents\Visual Studio 2008\Projects\IntellisenseFileTesting\IntellisenseFileTesting\Form1.cs:line 35
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at WindowsFormsApplication1.Program.Main() in C:\Users\mirapark\Documents\Visual Studio 2008\Projects\IntellisenseFileTesting\IntellisenseFileTesting\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
AnswerRe: Parsing XML file -exception because element node contains a space in name Pin
Samer Aburabie14-May-09 4:06
Samer Aburabie14-May-09 4:06 
GeneralRe: Parsing XML file -exception because element node contains a space in name Pin
Michael Dunn19-May-09 11:06
sitebuilderMichael Dunn19-May-09 11:06 
QuestionWriting an xml document Pin
dptalt12-May-09 5:55
dptalt12-May-09 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.