Click here to Skip to main content
15,888,454 members
Home / Discussions / XML / XSL
   

XML / XSL

 
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 
QuestionStoring binary data in xml file msxml and sending it to client through winsock Pin
hemlat11-May-09 20:27
hemlat11-May-09 20:27 
AnswerRe: Storing binary data in xml file msxml and sending it to client through winsock Pin
led mike12-May-09 4:38
led mike12-May-09 4:38 
QuestionStoring binary data in xml file msxml and sending it to client through winsock Pin
hemlat11-May-09 20:25
hemlat11-May-09 20:25 
AnswerRe: Storing binary data in xml file msxml and sending it to client through winsock Pin
Samer Aburabie14-May-09 4:09
Samer Aburabie14-May-09 4:09 
QuestionI am not able to read xml node in XPathNodeIterator Pin
Naveed72710-May-09 22:32
Naveed72710-May-09 22:32 
QuestionOIM in MSN15 getting error: invalid parameter Pin
amit090210-May-09 21:33
amit090210-May-09 21:33 
QuestionValidating XML file Pin
Sumit Prakash Sharma6-May-09 19:38
professionalSumit Prakash Sharma6-May-09 19:38 
AnswerRe: Validating XML file Pin
led mike7-May-09 4:37
led mike7-May-09 4:37 
QuestionXML / CSL Macros Pin
SimonCropper6-May-09 17:27
SimonCropper6-May-09 17:27 
AnswerRe: XML / CSL Macros Pin
led mike7-May-09 4:35
led mike7-May-09 4:35 
Questionchange attributes whitin XML Pin
Member 37528166-May-09 4:50
Member 37528166-May-09 4:50 
QuestionFinding an assembly redirection in app.config Pin
mav.northwind5-May-09 0:40
mav.northwind5-May-09 0:40 
AnswerRe: Finding an assembly redirection in app.config Pin
mav.northwind5-May-09 1:37
mav.northwind5-May-09 1:37 
QuestionSAXModelBuilder vs DOM Parser Pin
Josh Owen4-May-09 9:57
Josh Owen4-May-09 9:57 

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.