Dean Posted February 4, 2011 Report Share Posted February 4, 2011 Hello, stupid question. Have a large text file that is an XML styled file with repeating nested tag style. I would like save portions of the text file out to seperate text files. The sections I want to save begin and end with a tag. eg. <dataset fielda="xxxxxxxxxxxx" fieldb="xxxxxx" fieldc="xxxxxx" <value>example1</value> </dataset> I am attempting to use the Text file process feature of Macro Express. Silly question: How do I copy what is between the <dataset and </dataset> tags?, and save out as a textfile example1.txt I thought I could use the copy part of text file feature, and target the <dataset tag, and then specify the amount of lines, but thats when I got stuck, as it only has option to specify a fixed number of characters, which differ radically between each dataset. Please excuse my ignorance people, but is the above possible with Macro Express?. Thankyou kindly for your time. ..Dean.. Quote Link to comment Share on other sites More sharing options...
kevin Posted February 4, 2011 Report Share Posted February 4, 2011 <dataset fielda="xxxxxxxxxxxx" fieldb="xxxxxx" fieldc="xxxxxx" <value>example1</value> </dataset> Read the content of the file into a variable. Set one integer variable to the location of '<dataset'. Set another integer variable to the location of '</dataset>'. Then copy the data between. This untested sample should get you started: // Read content of file into a variable Variable Set String set %Content% to the contents of c:\TheFile.xml Variable Set Integer %Start% to the position of "<dataset" in %Content% // Find position of <dataset Variable Modify Integer: %Start% = %Start% + 8 // Adjust to skip over <dataset Variable Set Integer %End% to the position of "</dataset>" in %Content% // find position of </dataset> // Copy the data between the tags Variable Modify String: Copy a substring in %Content%, starting at %Start% and %End% characters long to %OneTag% After processing one tag you could delete it from the %Content% variable to get ready to process the next variable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.