can any one help to find a specific string between html tags
which is changed to a sting..
weather.html looks (for location) is
<location>somewhere</location>


#include <iostream>
#include <fstream>
#include <string>
using namespace std;

string find_field(string myPage,string);

int main (void) {

string page, line, location, temperature;
ifstream inputFile("weather.xml");

while(getline(inputFile, line)) {
page.append(line);
line.erase();
}
// Now page is a string that contains the whole xml page

// Here you need to write something that finds and
// extracts location and temperature from the XML
// data in the string page and stores them in
// the strings location and temperature respectively
location=find_field(page,"location");
temperature=find_field(page,"temp_c");

cout << "Location: "<<location << endl;
cout << "Temperature: " << temperature << endl;
system("pause");
}
string find_field(string myPage,string find_string){
int temp=myPage.find(find_string);
if(temp!=string::npos) {
cout << "Match found at " << temp << endl;

}

return "found?";
}

///


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C++ General Interview Questions

What is an overflow error?

0 Answers  


Check for Balanced Parentheses using Stack?

1 Answers  


What is a template in c++?

3 Answers  


Can we use resume in error handling i.e. in the catch block

5 Answers   Infosys,


this is to swap to strings....but in output the whole strings are swapped leaving first as it is...why it is so #include<iostream.h> int main() { char a[]="ajeet"; char b[]="singh"; long x=*a; long y=*b; cout<<x<<":"<<y; x=x+y; y=x-y; x=x-y; *a=x; *b=y; cout<<x<<":"<<y; cout<<&a<<endl; cout<<&b<<endl; }

1 Answers  


Should a constructor be public or private?

0 Answers  


What is time h in c++?

0 Answers  


what are Access specifiers in C++ class? What are the types?

0 Answers  


Give 2 examples of a code optimization?

4 Answers  


What is a static member?

0 Answers  


What is a lambda function c++?

0 Answers  


What is the type of this pointer in c++?

0 Answers  


Categories