removing linebreaks from xml files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Statix
    New Member
    • Mar 2008
    • 1

    #1

    removing linebreaks from xml files

    I written a vb.net app that reads the contents of an xml file and sets a textbox with one of the elements. I can read the file fine and seperate it but for the life of me can't figure out how to get the newlines from being displayed as 'squares' I've tried replacing them to no avail. here is what I've tried so far:

    Code:
               recDirections &= _step(i).InnerText
               recDirections.Replace(vbCr, " ")
               recDirections.Replace(vbLf, " ")
               recDirections.Replace(vbCrLf, " ")
               recDirections.Replace("\n", " ")
               recDirections.Replace(vbNewLine, " ")
               recDirections.Replace(Chr(10), " ")
               recDirections.Replace(Chr(13), " ")
               recDirections.Replace(Chr(10) & Chr(13), " ")
    none of these work and I'm at my witts end on this one. I think the problem is with the way the xml file is made, with returns on long lines so that it wraps but I'm not sure. If it is the case, it wouldn't solve my problem as the xml files are made by other users. Any ideas welcome
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Originally posted by Statix
    I written a vb.net app that reads the contents of an xml file and sets a textbox with one of the elements. I can read the file fine and seperate it but for the life of me can't figure out how to get the newlines from being displayed as 'squares' I've tried replacing them to no avail. here is what I've tried so far:

    Code:
    recDirections &= _step(i).InnerText
    recDirections.Replace(vbCr, " ")
    recDirections.Replace(vbLf, " ")
    recDirections.Replace(vbCrLf, " ")
    recDirections.Replace("\n", " ")
    recDirections.Replace(vbNewLine, " ")
    recDirections.Replace(Chr(10), " ")
    recDirections.Replace(Chr(13), " ")
    recDirections.Replace(Chr(10) & Chr(13), " ")
    none of these work and I'm at my witts end on this one. I think the problem is with the way the xml file is made, with returns on long lines so that it wraps but I'm not sure. If it is the case, it wouldn't solve my problem as the xml files are made by other users. Any ideas welcome
    Have you tried:
    recDirections = recDirections.R eplace(Chr(10), ControlChars.Cr )
    recDirections = recDirections.R eplace(Chr(13), ControlChars.Lf )

    You're not ending up replacing anything...beca use you're not actually assigning the directions with the replaced values to anything...

    Comment

    Working...