0

I am new to XML and have a very sketchy knowledge of C. I am writing a C program in which I need to read strings (each on a separate line) in a text file, match that string with a value enclosed in a specific tag inside an XML file, and based upon that match, get a value from inside another tag in the same XML file, and finally write that value to a new tag in a new XML file.

Can anyone please help me?

Thanks.

3
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by JenniLei
2

I am new to XML and have a very sketchy knowledge of C. I am writing a C program in which I need to read strings (each on a separate line) in a text file, match that string with a value enclosed in a specific tag inside an XML file, and based upon that match, get a value from inside another tag in the same XML file, and finally write that value to a new tag in a new XML file.

Well, being new to both probably puts you in a spot. You could write your own parser if the XML file will always and forevermore be canned and simple, and that might be easiest.

But I might also recommend looking into a third party library such as libXML if you are starting something that will grow and be adapted over time. This is what I chose when I needed to do XML parsing "for real".

Perhaps post an example of the XML file and the data to be extracted.

Some idea of simple parsing are here to give you some idea if you are not familiar with parsing text:
http://www.daniweb.com/code/snippet216535.html
http://www.daniweb.com/code/snippet216569.html
http://www.daniweb.com/code/snippet216682.html
http://www.daniweb.com/code/snippet216681.html

Votes + Comments
Excellent!
thorough
0

Luckily XML files are relatively easy to read and all you do is map from the tags in the xml docs. My advice in addition to Daves is to look at IXMLDOMDocument structure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.