aa

aa

  • NA
  • 10
  • 0

Need help with xpath and C#

Nov 5 2007 11:01 PM
Hi

I Have a file that is an xml file but it does contain html code. The xml code inside is mathml code. Mathml is for making math equations.

So you could have something like this:

<math xmlns='http://www.w3.org/1998/Math/MathML'>
   <mrow> </mrow>
               .
               .
               .
 </math>

Of course since you can have more then one equation you could have multiple statements of theses.

I am not trying to load up this file and filter out all these mathml code in it and stick is into its own file. So if my xml document has 6 of these mathml equations 6 files will be created.

I am kinda stuck on how to take this all out and then stick it into its own files.

I have been able to read in the the whole xml document but I can't figure out how to seperate the code into their own files.

 /* This checks to see if the user has clicked on the ok button to open the file */
            if (ofdOpenDocument.ShowDialog() != DialogResult.Cancel)
            {

                /* Makes a XmlDataDcoument called doc */
                XmlDataDocument doc = new XmlDataDocument();
                /* loads the users xml document they choose */
                doc.Load(ofdOpenDocument.OpenFile());
                /* finds all mathml root notes */
                XmlNodeList nodes = doc.SelectNodes("//*[local-name()='math']");
                /* tries to count how many equations there is */
                int equations = nodes.Count;
                /* tries to display it in a label */
                lblTest.Text = equations.ToString();

                /* this takes the total number of mathml tag roots it finds and makes a new link label for
                 * each node it finds. It then gives it a unquie name and adds it to the split container panel
                */
                for (int i = 1; i <= nodes.Count; i++)
                {
                    /*makes a dynamic label that will later be used to point to one of the newly created xml files
                     * that contain a mathml equation
                     */
                    LinkLabel makeLinkLabel = new LinkLabel();
                    makeLinkLabel.Text = " Equation " + i;
                    /* this adds the label to a flowlay out panel */
                    this.flpEquationDisplay.Controls.Add(makeLinkLabel);
                }
               

                
            }

        }