954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Converting an XML file to readable info

Hi all, I'm supposed to take an app which can parse the info of an xml document and output it into readable info, however I have no idea where to begin...
This is what I have so far:

private void button1_Click(object sender, EventArgs e)
        {

            XmlTextReader read = new XmlTextReader(@"C:\Documents and Settings\John\Desktop\content.xml");
            
            this.richTextBox1.Text = read.ToString();

        }


Obviously it's not close to working. It just displays 'System.Xml.XmlTextReader' into the textbox. Any help would be appreciated.

papanyquiL
Junior Poster
168 posts since May 2009
Reputation Points: 55
Solved Threads: 18
 

You can't very well convert an XML document in to something "human readable" without knowing the structure of the document. Elements could contain any number of child elements, etc etc. XML by itself is fairly readable if you understand you're looking at related data in my opinion.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

I see. Well, here's a small example of what it looks like:

<text:p text:style-name="P9">DEVELOPER SUPPORT SPECIALIST</text:p> 
  <text:p text:style-name="P10">SUMMARY OF QUALIFICATIONS / ACHIEVEMENTS</text:p> 
- <text:p text:style-name="P11">


Do you know how I could output that as plain readable text?

papanyquiL
Junior Poster
168 posts since May 2009
Reputation Points: 55
Solved Threads: 18
 

How do you want it formatted? That is the real question. And will it always be the same format or are you wanting this generic for all XML files?

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

I was wanting it to be able to be read into a rich textbox in plain text, without the xml tags. So, say, maybe I could have a open file dialog box and when someone selected an xml file, it would be put into plain text into the rich textbox (by plain text i mean the text without the xml tags). Thanks for your help.

papanyquiL
Junior Poster
168 posts since May 2009
Reputation Points: 55
Solved Threads: 18
 

Take a look at this page:
http://www.c-sharpcorner.com/uploadfile/mahesh/readwritexmltutmellli2111282005041517am/readwritexmltutmellli21.aspx

There is a lot of information that can be contained in XML. Its not just a straight forward "convert to rich text".

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

Ok, thanks Scott.

papanyquiL
Junior Poster
168 posts since May 2009
Reputation Points: 55
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You