CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2013
    Posts
    7

    Beginner Need Help!!!!

    I need to convert the .txt file in to .Xml file using c#, I can only able to convert half of the text, But I needed to convert in to a readable xml file containing its roots ant its each child elements.
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml;
    
    namespace Creating_Text_File_Using_Xml
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                XmlTextWriter XTW = new XmlTextWriter("savefile.xml", Encoding.Unicode);
                XTW.WriteStartDocument();
                XTW.WriteStartElement("XMLFILE");
                XTW.WriteStartElement("Title");
                XTW.WriteString(textBox1.Text);
                XTW.WriteEndElement();
                foreach(String item in listBox1.Items)
                {
                     XTW.WriteStartElement("Item");
                     XTW.WriteString(item);
                     XTW.WriteEndElement();
                }
                XTW.WriteEndElement();
                XTW.WriteEndDocument();
                XTW.Close();
    
            }
        }
    }
    This is the file i am trying to convert!!!!
    http://www.2shared.c...V1611Bible.html
    These are the words should be excluded from the file
    http://www.2shared.c...x9/exclude.html

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Beginner Need Help!!!!

    Why not use the XmlDocument class?

  3. #3
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    52

    Re: Beginner Need Help!!!!

    The links are broken, so could you provide the text you're trying to convert within a [code] tag instead?
    [sigpic][/sigpic]
    Microsoft MVP .NET Programming (2012 - Present)
    ®Crestron DMC-T Certified Automation Programmer

  4. #4
    Join Date
    Jan 2013
    Posts
    7

    Re: Beginner Need Help!!!!

    Once you have finished converting the text to XML
    example==>
    <ruth></ruth>
    <Ch13>contains some text</Ch13>
    and so on for the whole Bible
    if want to search a single word (eg brother)from the whole bible
    Then the
    xml look like
    <b>
    <r>
    <t>
    <brother> brother</brother>
    <item> some text contain brother1</item>
    <item> some text contain brother2</item>
    <item> some text contain brother3</item>
    </t>
    </r>
    </b>

  5. #5
    Join Date
    Jan 2013
    Posts
    7

    Re: Beginner Need Help!!!!

    Those links are not broken,
    one link is for the bible file that one you have to convert in to xml and then you have to do search
    second link is all the words you need to exclude when you doing the search

  6. #6
    Join Date
    Jan 2013
    Posts
    7

    Re: Beginner Need Help!!!!

    Those links are not broken,
    one link is for the bible file that one you have to convert in to xml and then you have to do search
    second link is all the words you need to exclude when you doing the search

  7. #7
    Join Date
    Jan 2013
    Posts
    7

  8. #8
    Join Date
    Jan 2013
    Posts
    7

    BIGINNER NEED HELP!!!!:wave::wave::wave::wave:

    I need to convert the bible text to XML Balanced Tree Index.
    First you have to convert each lines to XML.
    example:
    <line>1 text on the first line</line>
    <line>2 text on the 2nd line</line>
    <line>3 text on the 3rd line</line>
    <line>4 text on the 4th line</line>
    <line>5 text on the 5th line</line>
    <line>6 text on the 6th line</line>
    <line>7 text on the 7th line</line>
    for the whole bible text,
    Then you have create index XML
    should look like "aaron"
    <first text "a"></>
    <second text "a"></>
    <third text "r"></>
    <word text ="aaron"></>
    <line number> 122</> // these are the line which contain the word aaron when yo search the word "aaron"
    <line number> 132</> // these are the line which contain the word aaron
    <line number> 3222</> // these are the line which contain the word aaron

    "the bible txt"
    http://www.2shared.c...V1611Bible.html
    "Exclude word when you search"
    http://www.2shared.c...x9/exclude.html
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml;
    
    namespace Creating_Text_File_Using_Xml
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                XmlTextWriter XTW = new XmlTextWriter("savefile.xml", Encoding.Unicode);
                XTW.WriteStartDocument();
                XTW.WriteStartElement("XMLFILE");
                XTW.WriteStartElement("Title");
                XTW.WriteString(textBox1.Text);
                XTW.WriteEndElement();
                foreach(String item in listBox1.Items)
                {
                     XTW.WriteStartElement("Item");
                     XTW.WriteString(item);
                     XTW.WriteEndElement();
                }
                XTW.WriteEndElement();
                XTW.WriteEndDocument();
                XTW.Close();
    
            }
        }
    }
    The code i created is not complete!!!!
    Any One Knows how to do it!!!!

  9. #9
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Beginner Need Help!!!!

    [ Threads merged ]

    Please do not create duplicate threads on the same topic. Thanks!
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Beginner Need Help!!!!

    Links to download sites are deal killers for me. Not sure about other folks, but I'm leery about downloading from sites I'm not familiar with.

    So please, just zip up the two files and attach them to a reply directly.

  11. #11
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Beginner Need Help!!!!

    Not sure about other folks, but I'm leery about downloading from sites I'm not familiar with.
    Agreed.
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  12. #12
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    52

    Re: Beginner Need Help!!!!

    That was one of the reasons why I did not reply further. Although the original links were in fact broken, it looked like a copied version from being posted someplace else, because the link itself looked like it'd been shortened by a parser.
    [sigpic][/sigpic]
    Microsoft MVP .NET Programming (2012 - Present)
    ®Crestron DMC-T Certified Automation Programmer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured