Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

General XML Output script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    General XML Output script

    This xbasic script creates XML output from any table(s) you include in the variable TBLS. The output is for ALL fields in the table, and has this structure:

    HTML Code:
    <Records>
     <Table1Name>
      <FieldA>myvalue</FieldA>
      <FieldB>myvalue</FieldB>
     <Table1Name>
     <Table2Name>
      <FieldA>myvalue</FieldA>
      <FieldB>myvalue</FieldB>
     <Table2Name>
    </Records>
    HTML Code:
    'Date Created: 22-Dec-2007 09:27:29 AM
    'Last Updated: 22-Dec-2007 09:38:57 AM
    'Created By  : Steve Wood
    'Updated By  : Steve Wood
    
    'GENERAL UTILITY TO WRITE ALL TABLE RECORDS TO XLM OUTPUT
    'ASSUMES ALL TABLES ARE FILTERED ON THE SAME KEY FIELD AND FILTER VALUE
    'OUTPUT USES THE TABLE NAMES AS XML ELEMENT TAGS
    dim myfilter as c
    dim lst as c
    
    'THIS IS MY TEST VALUE, REMOVE OR REPLACE WITH YOUR OWN
    myfilter = "1106061328004846246" 'test value
     
    'NAME THE OUTPUT FILE
    xmlfile = "c:\records.xml"
    
    'LIST YOUR TABLE HERE.
    tbls = <<%txt%
    tr_trust_master
    tr_childbene
    %txt%
    
    'CODE BELOW CREATES OUTPUT.
    'CHANGE 'RECORDS' TO ANOTHER VALUE IF APPROPRIATE
    'NOTE MY FILTER IS BASED ON JOBID, CHANGE TO FIT YOUR SITUATION
    lst = "<Records>" + crlf()
    for each i in tbls
    tbl=table.open(i)
    query.filter = "Job_Id=" + s_quote(myfilter)
    query.order  = "Job_Id"
    query.options = "T"
    tbl.fetch_first()
    indx = tbl.query_create()
    WHILE .not. tbl.fetch_eof()
    	lst = lst + " <" + i + ">" + crlf()
    	flds=tbl.field_name_get()
    	FOR each foo in flds
    		fld = tbl.field_get(foo)
    		v = fld.value_get()
    		g = "  <"+foo+">"+alltrim(v)+"</"+foo+">"
    		lst = lst + g + crlf()
    next
    lst = lst + " </" + i + ">" + crlf()
    tbl.fetch_next()
    END WHILE
    indx.close()
    tbl.close()
    tbl.query_detach()
    next
    lst = lst + "</Records>"
    
    save_to_file(lst,xmlfile)
    Steve Wood
    See my profile on IADN


    #2
    Re: General XML Output script

    Here is some related code. My initial example dumped the entire contents of whatever table(s) you set in the 'tbls' variable. The new code below provides more control. I wanted to be able to determine which tables and fields were included in the xml export. The code is very compact and hard to follow, but does produce a nicely formed xml file.

    I created a table named xmlexport_detail (see attached image) which defined which tables and fields were to be included in the export. I can toggle any table in or out, or add or remove tables as necessary, same with any field.

    Notice in the attached image that I have Element Name (this is an arbitrary variable name, not the field name) and Element Expression. The script executes the Expression and saves the value to the Element (variable). Any xbasic function would work just as if I typed it manually in the script. Using this, I can write proper xml, such as:

    HTML Code:
    <Records>
     <Name>Steve Wood</Name>
     <Address>100 Main</Address>
     <Child>
      <Name>Mike</Name>
     </Child>
     <Child>
      <Name>Jane</Name>
     </Child>
    <Records>

    HTML Code:
    'Date Created: 22-Dec-2007 09:27:29 AM
    'Last Updated: 22-Dec-2007 09:38:57 AM
    'Created By  : Steve Wood
    'Updated By  : Steve Wood
    'Notes:
    ' - "Job_ID" is my key field for filter, replace with your own
    ' - replace my two lines setting "myfilter" with your own code to filter your tables
    ' - replace "xmlfile" with what you want your file named
    
    dim myfilter as c
    dim lst as c
    dim tbl as p
    myfilter = "8aed33a0f33049b2a644c46ac414fb60" ' test filter 
    xmlfile = "c:\ats\xml\records2.xml"
    
    lst = "<Records>" + crlf()
    
    tbls = table.external_record_content_get("xmlexport_master","alltrim(tablename)","exporder","exclude=.f.")
    for each h in tbls
    	flds = table.external_record_content_get("xmlexport_detail","alltrim(element_name) +' = '+ alltrim(element_exp)","","Exclude=.f. .and. tablename="+quote(h))
    	tbl=table.open("[PathAlias.ADB_Path]\\"+h)
    	query.filter = "Job_Id=" + s_quote(myfilter)
    	query.order  = "Job_Id"
    	query.options = "T"
    	tbl.fetch_first()
    	indx = tbl.query_create()
    	WHILE .not. tbl.fetch_eof()
    		lst = lst + " <"+h+">" + crlf()
    		for each j in flds
    			evaluate_template(evaluate_string(j))
    		next
    
    		FOR each i in flds
    			i = word(i,1)
    			lst = lst + "  <"+i+">" + "{"+i+"}" + "</"+i+">" + crlf()
    		next
    		lst = evaluate_string(lst)
    		lst = lst + " </"+h+">" + crlf()
    		tbl.fetch_next()
    	END WHILE
    	indx.close()
    	tbl.close()
    	tbl.query_detach()
    next
    lst = lst + "</Records>"
    
    save_to_file(lst,xmlfile)
    Steve Wood
    See my profile on IADN

    Comment


      #3
      Re: General XML Output script

      Slight modification for the script below. There are two FOR EACH loops referencing the variable "flds". Apparenly you can't use the same variable in two different FOR EACH loop, or at least in this case. So, add this:

      flds2 = flds ' just under where it sets the value for flds

      and then use flds2 in the second loop, as in:

      FOR each i in flds2
      Steve Wood
      See my profile on IADN

      Comment

      Working...
      X