Hi,
I have a XML file generated externally,i need to traverse through that file and then make certain changes to the XML file or add new attributes to that file.How can i go about it?This eventually will be a Pro*C code.Kindly help me out.Thanks.

Its just a normal text file, so just use standard stream io on it. Other than that advise its impossible for anyone to tell you more from what little you write. Sort of like walking into an auto repair ship and saying "My car doesn't work can you tell me how to fix it?".

I have a Pro*C code which fetches data from the DB.This data needs to be either appended for the matching tags with the XML file generated from a external source or else it needs to be added at the end of the XML file.The data that i am fetching is the missing data that needs to be incorporated in the XML.And some of the data are a fresh requirement and needs to get added to the existing XML file.The XML file consists of thousands of Invoice in them.So how do i traverse each record? Getting into more detail say this Invoice that exists has missing data like the customers Telephone no. etc. This is fetched in the Pro*C code and i need to Traverse the XML file w.r.t the invoice_no which being common in both XML and the fetched data.So kindly help me out as to how can i go about the whole process and sample code would be definitely helpful.thanks.

>>This is fetched in the Pro*C code
Pro*C is a compiler, not a language. So you can use any C compiler you want.

Don't expect a quick solution to your problem because there isn't one. Here is one example of parsing html code. You just have to search though each line of the html file and insert whatever you want. There is no magic way to do it.

>>So how do i traverse each record? Getting

std::string line
ifstream in("filename.htm");
ofstream out("newfile.htm");
while( getline(in, line) )
{
    // search and replace text here
    //
    // now rewrite the line
    out << line << "\n";
}

You might also check out boost libraries string tokenization. I've never used it, but looks promising for your program.

Maybe the net framework class library for xml which can virtually used with every programming languages (I myself use it together with c++) solves some of your problems.
http://msdn.microsoft.com/en-us/library/system.xml(VS.80).aspx
some years ago when i started with xml i really wrote my own xml parser an did manipulate xml files with plain string methods. Thanks net framework class lib now it s something easier to deal with xml.

krs,
tesu

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.