Read XML from application variable instead of file

G

gn

Due to the production servers being a multiple server farm and not
being able to write xml files to them, I am having to change my
application to write to HttpContext.Current.Application("var")
I have succeeding in doing this part, my problem is now how to read
them. I kinda hoped that I would be simply able to change

m_xmlr = New XmlTextReader(path/var.xml"))

to

m_xmlr = New
XmlTextReader(HttpContext.Current.Application("var").ToString)

here is my current code - what changes would I need to make?

m_xmlr = New XmlTextReader(path/var.xml"))
'Disable whitespace so that you don't have to read over
whitespaces
m_xmlr.WhitespaceHandling = WhitespaceHandling.None
'read the xml declaration and advance to family tag
m_xmlr.Read()
'Load the Loop
While Not m_xmlr.EOF
'Go to the name tag
m_xmlr.Read()
'if not start element exit while loop
If Not m_xmlr.IsStartElement() Then
Exit While
End If
m_xmlr.Read()
Dim C_TitleValue As String =
m_xmlr.ReadElementString("C_TITLE")
'Get the comment Element Value
Dim C_CommentValue As String =
m_xmlr.ReadElementString("C_COMMENT")
'Get the URL Element Value
Dim C_URLValue As String =
m_xmlr.ReadElementString("C_URL")
'Get the listorder Element Value
Dim C_ListorderValue As String =
m_xmlr.ReadElementString("C_LISTORDER")
'Iterate through writing values from XML file into the
table string

thanks so much, as always I am on a deadline
 
B

bruce barker

if I know my vb well enough.

m_xmlr = New XmlTextReader(new
StringReader(HttpContext.Current.Application("var").ToString))

you do know that HttpContext.Current.Application is local to the server, and
not shared across a web farm

-- bruce (sqlwork.com)

| Due to the production servers being a multiple server farm and not
| being able to write xml files to them, I am having to change my
| application to write to HttpContext.Current.Application("var")
| I have succeeding in doing this part, my problem is now how to read
| them. I kinda hoped that I would be simply able to change
|
| m_xmlr = New XmlTextReader(path/var.xml"))
|
| to
|
| m_xmlr = New
| XmlTextReader(HttpContext.Current.Application("var").ToString)
|
| here is my current code - what changes would I need to make?
|
| m_xmlr = New XmlTextReader(path/var.xml"))
| 'Disable whitespace so that you don't have to read over
| whitespaces
| m_xmlr.WhitespaceHandling = WhitespaceHandling.None
| 'read the xml declaration and advance to family tag
| m_xmlr.Read()
| 'Load the Loop
| While Not m_xmlr.EOF
| 'Go to the name tag
| m_xmlr.Read()
| 'if not start element exit while loop
| If Not m_xmlr.IsStartElement() Then
| Exit While
| End If
| m_xmlr.Read()
| Dim C_TitleValue As String =
| m_xmlr.ReadElementString("C_TITLE")
| 'Get the comment Element Value
| Dim C_CommentValue As String =
| m_xmlr.ReadElementString("C_COMMENT")
| 'Get the URL Element Value
| Dim C_URLValue As String =
| m_xmlr.ReadElementString("C_URL")
| 'Get the listorder Element Value
| Dim C_ListorderValue As String =
| m_xmlr.ReadElementString("C_LISTORDER")
| 'Iterate through writing values from XML file into the
| table string
|
| thanks so much, as always I am on a deadline
|
 
G

gn

you do know that HttpContext.Current.Application is local to the
server, and
not shared across a web farm

from what I understand in our case that is stored in a sql server,
though I could be wrong?
 
G

gn

Your solution to the original question worked great by the way.

Thanks so much!

Won't get to test it on the server farm until I am ready to promote to
production, not an ideal setup but not my choice

thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top