[DLL] XML Parser?

Post all your application ideas, thoughts and suggestions in here to inspire others or kick-off a project.
9 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

[DLL] XML Parser?
GoodGuy17
Hello,

I have an idea for anyone willing. Maybe you could create an XML parser? Not only would it give you an idea, but it would help people like me, who can't really figure out how to parse it manually. It could be called simply, like:

ParseXML.ReadVal("valname")

and maybe even a write function.

I hope someone does this :)

~GoodGuy17 :D
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: [DLL] XML Parser?
MrAksel
Can't you just use the System.XML namespace? There are plenty of classes for parsing XML there.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: [DLL] XML Parser?
Axel
Lol easy to do with Regular expressions , I wrote a html parser before which is very much like xml, but you should just use System.XML, no need to rewrite that
http://vagex.com/?ref=25000
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: [DLL] XML Parser?
M1z23R
It is not that similar, there are some major differences. Maybe i'll try to make one.
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: [DLL] XML Parser?
Axel
The essence is in there
<tagname> </endswithslash>
http://vagex.com/?ref=25000
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: [DLL] XML Parser?
MrAksel
Axel wrote:
Lol easy to do with Regular expressions , I wrote a html parser before which is very much like xml, but you should just use System.XML, no need to rewrite that
Regex is not the right tool for XML or HTML. You need an enormous expression to handle incorrect input in addition to the valid HTML. I would be suprised to see anyone at mandais level make a HTML/XML parser with regex.
There are several small regexes to catch simple tags, but once a nested tag with the same identifier occours (<tagID bla=""><tagID bla="nested tag"></tagID></tagID>), you will have large problems. The regex
<([A-Z][A-Z0-9]*)\b[^>]*>.*?</\1> will match a tag with no nested identical tags. In the string <tagID bla=""><tagID bla="nested tag"></tagID></tagID> this regex will match <tagID bla=""><tagID bla="nested tag"></tagID></tagID>
If you make a little adjustment, and make one of the stars greedy, in the HTML file

<div>
</div>
<div>
</div>

the regex would match
<div>
</div>
<div>
</div>
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: [DLL] XML Parser?
Axel
Parsing big files actually doesn't take long. Instead of [A-Z][A-Z0-9] I'd use [\w|\W]+ instead
http://vagex.com/?ref=25000
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: [DLL] XML Parser?
MrAksel
I didnt say anything about how long it takes, just how many flaws it would create. \w is the same as [A-Z][A-Z0-9]
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: [DLL] XML Parser?
Axel
I know it is, but your regex could be optimized to be much shorter. And that one is basic, if you keep improving it it wont create any flaws
I made some code for parsing subtitle formats (srt & ass) and it was much longer than that piece lol
http://vagex.com/?ref=25000
9 posts Page 1 of 1
Return to “Code Storming”