Hi i am new in this world, so i need some help with this. I need to make a program in c++ or c, receive an xml file, and the program count the file labels (<Home> <\Home>) and say how many time repeats the same label.

Thanks

Recommended Answers

All 3 Replies

Here's something for you:
I/O on files: Click Here

For the XML part:
a. use some libraries for parsing the file:
TinyXML: Click Here
Xerces: Click Here

b. use regex for matching:
Here's an online tool to test your regex:Regex101

c. brute parse the file and count the <home> and </home> tags

thanks for the tips bro. But now i'm having a little issue. by example i declare my regular expression like
string regex_str = "[a-z]+";
and in my file i have strings like

asd
dfghj
afghyt
s
f

So in theory, the regular expression must recognize all expressions in letters between a and z, with all combinations. Interestingly only recognized when a single letter come, is like if my regular expression is [a-z] without +, if I try whit * the same thing happens only recognizes the letter alone. You have some recommendation for this

Maybe something like this: Click Here

You're explanation: yes, indeed, it has to match all characters between a-z, but, when it meets a blank space, it will stop, since ' ' is not part of the 'a-z' range.

Use '\b[what_to_search]\b' to search as words, since '\b' stands for word boundary, or try using this regex \w+ for matching only words, but this will match also digits.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.