Remove a portion of a string value?

tealmad

Member
Joined
Jul 12, 2005
Messages
6
Location
USA
Programming Experience
1-3
I am thinking of the best way to remove part of a string. Here is my String value:


Code:
VB.NET:
<ul>
  <ul>
    <ID>98</ID>
    <li>Online CIO</li>
    <ul>
      <ID>99</ID>
      <ParentID>98</ParentID>
      <li>Add CIO</li>
    </ul>
    <ul>
      <ID>100</ID>
      <ParentID>98</ParentID>
      <li>View CIOs</li>
    </ul>
  </ul>
</ul>
I am looking to remove the lines within the string that have <ID>ANY VALUE</ID>, and <ParentID>ANY VALUE</ParentID>.

What would be the best way to do this? Any help is appreciated.
 
As the "string" posted fits as Xml structure I moved it to Xml forum and propose this solution below. There no indication in your post that the problem is Forms related anyway so it doesn't belong in the Forms forum.
VB.NET:
Dim doc As New Xml.XmlDocument
doc.Load("input.xml")
For Each id As Xml.XmlNode In doc.SelectNodes("//ID")
    id.ParentNode.RemoveChild(id)
Next
doc.Save("output.xml")
 
Well, as I have seen a lot of examples on the web that use the proposed method. However, I cannot use this method I think... ???

What I have is a dataset that has my navigation links along with a Parent/Child relationship. I am trying to take that data from the dataset and placing it into a CSS Custom Menu. I cannot use the menu control that ASP.Net provides as it cannot do what I need it to do. So to sum it up, I am taking the data from the dataset and building a uniform list, which is what my CSS will read, and convert to a menu. :)

I am using the following to get the data from the dataset:

Dim myDataset as New Dataset
Dim myString as string = vbnullstring
....Code Omitted....
myString = myDataset.GetXml()

I have been trying to use the XmlDocument to load the string, but it doesn't like it. I get the error that the path has illegal characters. Therefore, it is looking for a physical file location, of which I don't want to do.

I there another way you could suggest? I don't need code, I just need some logic that will allow me to do what it is that I am trying to accomplish.

Thanks in advance!!
 
Back
Top