XML Data Source?


Author
Message
ckelsoe
ckelsoe
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 13, Visits: 97
Is there methods to read from an XML file available within the framework? I can not seem to find any reference to this but may be missing something. I need to read from an XML file and do stuff with the data.

Charles R Kelsoe
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Charles,

It's good to hear from you. Smile  There are several ways to do this.  I cannot remember what language you are using, but you can create a business object and pull its structure from an existing database or from the BO mapper solely for the purpose of strong-typing the BO through the BO Mapper.  However, to pull the data from an XML file and then interact with that data through the BO and then save it back to the XML file, you will need to add code similar to this:

    ''' <summary>
    ''' Create a method for loading the XML file
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub FillFromXMLFile()
        '-- Establish Locals
        Dim loTable As New DataTable()

        '-- Load the XML file into a data table
        loTable.ReadXml("c:\temp\myxmlfile.xml")

        '-- Move the data from the XML file into the business object
        Me.CopyDataFrom(loTable, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

        '-- Smoke the temp data table
        loTable.Dispose()
    End Sub

    ''' <summary>
    ''' Overwrite the save so it will update the XML file
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shadows Function Save() As MicroFour.StrataFrame.Data.SaveUndoResult
        '-- Establish Locals
        Dim loReturn As MicroFour.StrataFrame.Data.SaveUndoResult = MicroFour.StrataFrame.Data.SaveUndoResult.Success

         Try
           '-- If changes exist, the update the XML file
            If Me.IsDirty Then
                '-- Remove any existing file
                If System.IO.File.Exists("c:\temp\myxmlfile.xml") Then
                    System.IO.File.Delete("c:\temp\myxmlfile.xml")
                End If

                '-- Write the changes back
                CurrentDataTable.WriteXml("c:\temp\myxmlfile.xml", True)

                '-- Update the internal data table so the BO is no longer dirty
                Me.CurrentDataTable.AcceptChanges()
            End If

        Catch ex As Exception

            loReturn = MicroFour.StrataFrame.Data.SaveUndoResult.Cancelled

        End Try

         '-- Return the results
        Return loReturn

    End Function

Let me know if this gets you going in the right direction.  If not, I will create you a sample and send it your way.  Thanks and it was really good to see your name on the posts.

ckelsoe
ckelsoe
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 13, Visits: 97
Trent, I have been very busy with other endevors - an office move, data conversion, lob app implemention - so not a lot of time to learn StrataFrame.

Here is what I need to do - I have a bunch of XML file of which some contain data that I need. So I will iterate through a file structure, look in each file for an xml tag that I am looking for. If i find the file, then, I will need to delve further into the file and retrieve several rows of data. Once I retrieve it, I will stuff it into a database for other use. Ultimately I will have to make a bunch of Excel files.  

I am going to use XmlDOcument to read through the file unless there is a more effecient way to do this in StrataFrame.

I use VB.Net.

Charles

Charles R Kelsoe

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, it is good to see online again.  I want to help you get going any way that I can, so just let me know what I can do to help.

For starters, an XmlDocument will work fine.  If you are looking for speed though, you may want to use an XmlReader.  My suggesstion would depend on the expected size of the XML files.  If they are going to be very large, then you would definitly want to use an XmlReader because it does not require the entire file to be read into memory before it can be used.  Downside is that it requires a little more work.  However, if they are smaller, you can load them up very quickly into an ADO.NET data table and/or a StrataFrame business object and perform queries on the loaded data.

Do you want to be able to interact with the XML data through a business object that can be dropped on a Win or Web form?  If so, then we want to get the XML file into an ADO.NET data table so it can be moved into a business object.  This would be similar to the code snippet I provided earlier.

ckelsoe
ckelsoe
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 13, Visits: 97
If you like, I can send you a sample of the file so you can see exactly what I am trying to do.

Charles R Kelsoe
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
That would be great!  You can just send it to my direct email.  I will PM you and give it to you just in case you don't have it.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search