Home Hex Edit Home Page
Hex Edit Features Hex Edit Features
Button Testimonials
Button Screen Shots
Button Downloads
Button Forums Home
Button HexEdit FAQ
Button Known Bugs
about help privacy register
Forums
Search Members Help

» Welcome Guest
[ Log In :: Register ]

 

[ Track This Topic :: Email This Topic :: Print this topic ]

reply to topic new topic new poll
Topic: Template for XML data< Next Oldest | Next Newest >
 Post Number: 1
dginley Search for posts by this member.

Avatar



Group: Members
Posts: 3
Joined: Feb. 2005

Member Rating: None
PostIcon Posted on: Dec. 18 2008,16:18  Skip to the next post in this topic. Ignore posts   QUOTE

I'm using version 3.1 and trying to build a template for a file of binary data, but with an xml header at the beginning of the file. The binary part is simple, but I'm having trouble with the header:
1) the length of the header is unknown, so I can't just read a given number of lines, and
2) every line of the header except the last is terminated with a crlf, so I can't just read lines that way, as is done in the template tutorial.

The header is of the format
<StorageToolkt>
   many lines of data
</StorageToolkt>binary date begins here

As I said above, the </StorageToolkt> line does not have a crlf at its end; the very next byte is the beginning of the data. It seems that I should be able to use the string "</StorageToolkt>" to stop reading the header, but when I try that I read one byte too many. Am I missing something obvious here?

Thanks for any suggestions,
Dennis
Offline
Top of Page Profile Contact Info 
 Post Number: 2
andrew Search for posts by this member.

Avatar



Group: Super Administrators
Posts: 635
Joined: Oct. 2003

Member Rating: 4
PostIcon Posted on: Dec. 21 2008,02:34 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

If you use a string in a template and don't specify a length then the string continues until EOF or a string terminator is encountered.  By default the string terminator is a nul (00) byte but you can set it to any byte value even '>'.

You should also try using 3.3 as there have been some bug fixes for templates.


--------------
Andrew Phillips
Moderator of Forums and creator of Hex Edit
Offline
Top of Page Profile Contact Info WEB 
 Post Number: 3
dginley Search for posts by this member.

Avatar



Group: Members
Posts: 3
Joined: Feb. 2005

Member Rating: None
PostIcon Posted on: Jan. 05 2009,10:07 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

Thanks for the reply, Andrew.

Using '>' as the string terminator works for the individual strings, but then the question becomes how to stop the FOR loop. I'm assuming a FOR loop is the way to go, since I need to read an unknown number of strings in the header before I get to the data.

If I try thisHeaderline == "</StorageToolkit>"" I get the message Illegal operand types for comparison in "stop_test" of "for"

If I try it without the quotes, i.e. thisHeaderline == </StorageToolkit> the message is Unexpected characters "</" in "stop_test" of "for"

I've tried several other things, but I'm not getting anywhere.

Thanks,
Dennis
Offline
Top of Page Profile Contact Info 
 Post Number: 4
andrew Search for posts by this member.

Avatar



Group: Super Administrators
Posts: 635
Joined: Oct. 2003

Member Rating: 4
PostIcon Posted on: Jan. 10 2009,15:58 Skip to the previous post in this topic.  Ignore posts   QUOTE

First:

CODE
this.Headerline == "</StorageToolkit>"


is a valid expression if this.Headerline is a string.


There are several ways you could approach this.  Possibly the simplest would be to read lines of (CR/LF terminated) text, and look forward after each one for </StorageToolkit>.  This assume the text is always exactly like this - ie no leading or trailing whitespace and no spaces eg between / and S.

To look forward you need to use a JUMP, so that the file position goes back to the start of the string.  If you detect the end of header you then just need to skip 17 bytes (the length of "</StorageToolkit>") and begin the binary processing.

If you don't understand this or have more problems send me the template you have and a small example file and I will have a look at it.  Email to aphillips @ hexedit.com with "HexEdit" somewhere in the subject, but also put a reply here to make sure I look for the email.  It seems to get lost or SPAM at times.


--------------
Andrew Phillips
Moderator of Forums and creator of Hex Edit
Offline
Top of Page Profile Contact Info WEB 
3 replies since Dec. 18 2008,16:18 < Next Oldest | Next Newest >

[ Track This Topic :: Email This Topic :: Print this topic ]


 
reply to topic new topic new poll

» Quick Reply Template for XML data
iB Code Buttons
You are posting as:

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code