Read XML from application variable instead of file

Discussion in 'ASP .Net' started by gn@dana.ucc.nau.edu, Feb 18, 2005.

  1. Guest

    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
     
    , Feb 18, 2005
    #1
    1. Advertising

  2. bruce barker Guest

    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)

    <> wrote in message
    news:...
    | 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
    |
     
    bruce barker, Feb 18, 2005
    #2
    1. Advertising

  3. Guest

    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?
     
    , Feb 18, 2005
    #3
  4. Guest

    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
     
    , Feb 18, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CVerma
    Replies:
    2
    Views:
    10,328
    C Verma
    Sep 28, 2004
  2. th3dude
    Replies:
    5
    Views:
    190,124
    th3dude
    Jun 5, 2006
  3. Replies:
    6
    Views:
    1,165
    James Dow Allen
    Feb 17, 2010
  4. Alex Dowad
    Replies:
    4
    Views:
    316
    Michel Demazure
    May 1, 2010
  5. Erik Wasser
    Replies:
    5
    Views:
    520
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page