?
Solved

Removing statements from xml files

Posted on 2007-04-10
5
Medium Priority
?
155 Views
Last Modified: 2010-04-23
Hello Experts,

I have to remove below mentioned statements from xml files....there are multiple types of such statements..


1. <?xml:stylesheet type="text/xsl" href="../../home.xsl" ?>
2. <?xml:stylesheet type="text/xsl" href="../../page.xsl" ?>

also there are attributes such as below...there are multiple xsd's which needs to remove with attribute.

1. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2. xsi:noNamespaceSchemaLocation="../../home.xsd"
3. xsi:noNamespaceSchemaLocation="../../page.xsd"


Is there any way to implement such type of task using vb.net? or any references for the same?

Thanks,
Shailesh
0
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 18887714
Why not? Just read it line by line and compart it to the string you like to install, then write out another file with the stuff you want deleted beeing ommitted.

Regards
Friedrich
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 18887803
Hello Expert,

I am doing something like this....

Private Sub cmdPreProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPreProcess.Click
        Dim mydir As New DirectoryInfo(mstrFolderXMLFiles)
        mydir = New DirectoryInfo(mstrFolderXMLFiles)
        WorkWithDirectory(mydir)
    End Sub
    Public Shared Sub WorkWithDirectory(ByVal aDir As DirectoryInfo)
        Dim nextDir As DirectoryInfo
        WorkWithFilesInDir(aDir)
        For Each nextDir In aDir.GetDirectories
            WorkWithDirectory(nextDir)
        Next
    End Sub
    Public Shared Sub WorkWithFilesInDir(ByVal aDir As DirectoryInfo)
        Dim aFile As FileInfo
        For Each aFile In aDir.GetFiles("*.xml")
            Dim sr As StreamReader = New StreamReader(aFile.FullName)
            Dim content As String = sr.ReadToEnd()
            sr.Read()
            Dim strFull As String
            Dim strOriginal As String = "<?xml:stylesheet type="text/xsl" href="../../home.xsl" ?>"
            Dim strReplace As String = ""
            strFull = content.Replace(strOriginal, strReplace)
            MsgBox(strFull)
        Next
    End Sub


But here it's not finding "strOriginal", what needs to be done instead of this?

Thanks,
Shailesh
0
 
LVL 24

Accepted Solution

by:
fridom earned 750 total points
ID: 18887866
Is it really written the mentioned way? I can see at least a few problems:
You write your string with " but within the string you use " also that means it will end the string, so this code cna not compile that way. At least you ahve to quote your " properly.

Regards
Friedrich
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 18887868
Yeah..it does not compile it..ask for end of statement..for strOriginal
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 18887881
Hello Expert,

I got it i need to put something like this....."<?xml:stylesheet type=""text/xsl"" href=""../../home.xsl"" ?>"

Thanks,
Shailesh
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question