Replacing a section of a response.write string

Hello,

i am trying to replace a section of my string with a new section i was thinking i could use a sub string but had no luck

current string section
<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" >

desired string section
<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="urn:chris-jones.com">
LVL 1
Chris JonesLead Application Web DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russ SuterCommented:
string.replace(oldString, ">", "xmlns:media="""urn:chris-jones.com""">")
0
Chris JonesLead Application Web DeveloperAuthor Commented:
there is a lot more after that string i am afraid that would replace everywhere there is a >
0
Russ SuterCommented:
Then can you clarify your question? The solution I provided would work for the question you asked.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Chris JonesLead Application Web DeveloperAuthor Commented:
Hello,

sorry i though when i stated section it would have helped. So the string is within text so i have teh following text

FULL TEXT BEFORE
<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"

<channel><title>ROAR</title><link>https://ems.tamuc.edu/MasterCalendar/</link><description /><pubDate>Thu, 16 Jul 2015 20:30:51 GMT</pubDate><lastBuildDate>Thu, 16 Jul 2015 20:30:51 GMT</lastBuildDate><category>Calendar of Events</category><atom:link href="https://ems.tamuc.edu/MasterCalendar/RSSFeeds.aspx?data=3O4bL1MF%2bEvmo4ssXvqg4VIdJVQ7Ikut" rel="self" type="application/rss+xml" /><generator>Texas A&amp;M University-Commerce Calendar</generator><copyright>2015</copyright><ttl>30</ttl><item><title><![CDATA[TEST ROAR]]></title><description xml:space="preserve"><![CDATA[ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.]]></description><category>ROAR</category><pubDate>Fri, 31 Jul 2015 14:00:00 GMT</pubDate><link>https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J76SQ35oOF3IPdZaU9dlwj%2bXOIAe6lXfnafXiNaobF2duwB6Mb%2f%2biZF</link><guid>https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J76SQ35oOF3IPdZaU9dlwj%2bXOIAe6lXfnafXiNaobF2duwB6Mb%2f%2biZF</guid>
<media:content url="https://ems.tamuc.edu/MasterCalendar/imagewriter.aspx?imageId=509" type="image/jpeg" medium = "image">

</media:content>
</item>

<item>
<title>
<![CDATA[ Test 2 ]]>
</title>
<description xml:space="preserve">
<![CDATA[
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 'de Finibus Bonorum et Malorum' (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, 'Lorem ipsum dolor sit amet..', comes from a line in section 1.10.32.
]]>
</description>
<category>ROAR</category>
<pubDate>Fri, 31 Jul 2015 14:00:00 GMT</pubDate>
<link>
https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J5QDcCPKfKKiKFt93KHPDnsAq9jE7qy0yKoarMUiGDmkgkBF3g3kO8u
</link>
<guid>
https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J5QDcCPKfKKiKFt93KHPDnsAq9jE7qy0yKoarMUiGDmkgkBF3g3kO8u
</guid>
<media:content url="https://ems.tamuc.edu/MasterCalendar/imagewriter.aspx?imageId=510" type="image/jpeg" medium = "image">
</media:content>
</item>

</channel></rss>

Open in new window


FULL TEXT AFTER

<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="urn:chris-jones.com">

<channel><title>ROAR</title><link>https://ems.tamuc.edu/MasterCalendar/</link><description /><pubDate>Thu, 16 Jul 2015 20:30:51 GMT</pubDate><lastBuildDate>Thu, 16 Jul 2015 20:30:51 GMT</lastBuildDate><category>Calendar of Events</category><atom:link href="https://ems.tamuc.edu/MasterCalendar/RSSFeeds.aspx?data=3O4bL1MF%2bEvmo4ssXvqg4VIdJVQ7Ikut" rel="self" type="application/rss+xml" /><generator>Texas A&amp;M University-Commerce Calendar</generator><copyright>2015</copyright><ttl>30</ttl><item><title><![CDATA[TEST ROAR]]></title><description xml:space="preserve"><![CDATA[ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.]]></description><category>ROAR</category><pubDate>Fri, 31 Jul 2015 14:00:00 GMT</pubDate><link>https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J76SQ35oOF3IPdZaU9dlwj%2bXOIAe6lXfnafXiNaobF2duwB6Mb%2f%2biZF</link><guid>https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J76SQ35oOF3IPdZaU9dlwj%2bXOIAe6lXfnafXiNaobF2duwB6Mb%2f%2biZF</guid>
<media:content url="https://ems.tamuc.edu/MasterCalendar/imagewriter.aspx?imageId=509" type="image/jpeg" medium = "image">

</media:content>
</item>

<item>
<title>
<![CDATA[ Test 2 ]]>
</title>
<description xml:space="preserve">
<![CDATA[
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 'de Finibus Bonorum et Malorum' (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, 'Lorem ipsum dolor sit amet..', comes from a line in section 1.10.32.
]]>
</description>
<category>ROAR</category>
<pubDate>Fri, 31 Jul 2015 14:00:00 GMT</pubDate>
<link>
https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J5QDcCPKfKKiKFt93KHPDnsAq9jE7qy0yKoarMUiGDmkgkBF3g3kO8u
</link>
<guid>
https://ems.tamuc.edu/MasterCalendar/EventDetails.aspx?data=hHr80o3M7J5QDcCPKfKKiKFt93KHPDnsAq9jE7qy0yKoarMUiGDmkgkBF3g3kO8u
</guid>
<media:content url="https://ems.tamuc.edu/MasterCalendar/imagewriter.aspx?imageId=510" type="image/jpeg" medium = "image">
</media:content>
</item>

</channel></rss>

Open in new window

0
ChloesDadCommented:
You can still use string.replace, but just use a unique string that only occurs once in the text that you have. It means that the strings are a bit longer, but they have to be to make it unique

oldstring="<rss version="""2.0""" xmlns:atom="""http://www.w3.org/2005/Atom""" >"
newString = "<rss version="""2.0""" xmlns:atom="""http://www.w3.org/2005/Atom""" xmlns:media="""urn:chris-jones.com""">"

FullString.Replace(oldString,NewString)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris JonesLead Application Web DeveloperAuthor Commented:
Hello,

i did the following code in .net but the text still did not seem to get replaced

            CorrectEnclosure.Replace("<rss version=""2.0"" xmlns:atom=""http: //www.w3.org/2005/Atom"">", "<rss version=""2.0"" xmlns:atom=""http:  //www.w3.org/2005/Atom"" xmlns:media=""urn:chris-jones.com""> ")

Open in new window

0
ChloesDadCommented:
Sorry, its a function, so you need

newstring=oldstring.replace(x,y)

Open in new window

0
Chris JonesLead Application Web DeveloperAuthor Commented:
Hello,

i did the following but the text did not get replaced do you see anything i am missing


          Dim oldstring As String = "<rss version=""""2.0"""" xmlns:atom=""""http://www.w3.org/2005/Atom"""" >"
            Dim newString As String = "<rss version=""""2.0"""" xmlns:atom=""""http://www.w3.org/2005/Atom"""" xmlns:media=""""urn:chris-jones.com"""">"
            CorrectEnclosure.Replace(oldstring, newString)

Open in new window

0
Chris JonesLead Application Web DeveloperAuthor Commented:
just an update i changed back to your origional code but its telling me that there no end of statement error since its trying to execute the "" 

            Dim oldstring As String = "<rss version="""2.0""" xmlns:atom="""http://www.w3.org/2005/Atom""">"
            Dim newString As String = "<rss version="""2.0""" xmlnsatom = """http://www.w3.org/2005/Atom""" xmlns:media="""urn:chris-jones.com""">"
            CorrectEnclosure.Replace(oldstring, newString)

Open in new window

0
Chris JonesLead Application Web DeveloperAuthor Commented:
ok so here is what i did but the same result no replacing

    Const DblQts As String = """"


            Dim oldstring As String = "<rss version=" & DblQts & "2.0" & DblQts & " xmlns:atom=" & DblQts & "http://www.w3.org/2005/Atom" & DblQts & ">"
            Dim newString As String = "<rss version=" & DblQts & "2.0" & DblQts & " xmlns:atom = " & DblQts & "http://www.w3.org/2005/Atom" & DblQts & " xmlns:media= " & DblQts & "urn:chris-jones.com" & DblQts & ">"
            CorrectEnclosure.Replace(oldstring, newString)

Open in new window

0
ChloesDadCommented:
You need

CorrectEnclosure = CorrectEnclosure.Replace(oldstring, newString)

Open in new window


as replace is a function not a method
0
Chris JonesLead Application Web DeveloperAuthor Commented:
Awesome sorry i overlooked that . so that did the trick thank you so much
0
ChloesDadCommented:
No problem, Could you accept the answer then please :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.