XMLFile parsing using file operationsXML Parser for CWhy can templates only be implemented in the header file?Parsing XML Encoded in UTF-8Return value for a << operator function of a custom string class in C++What is the “-->” operator in C++?How to override the ++ operator in C++ and then print the output using an overriden << operator?What are the basic rules and idioms for operator overloading?Error trying to use pthread on UbuntuGetting very long “No match for 'operator+'” error in C++C++: concatenate an enum to a std::stringGetting Error when reading file in string using C++Builder Project
What is the most convenient way to prepare ferrous oxide (FeO) in the laboratory?
Is my investment strategy a form of fundamental indexing?
Why is drive/partition number still used?
How many oliphaunts died in all of the Lord of the Rings battles?
What do I do with a party that is much stronger than their level?
Request for a Latin phrase as motto "God is highest/supreme"
Why is it considered Acid Rain with pH <5.6
Did the Americans trade destroyers in the "destroyer deal" that they would later need themselves?
Is cardinality continuous?
Assuring luggage isn't lost with short layover
When does Haskell complain about incorrect typing in functions?
Learning Minor scales through 7 patterns (Guitar)
What is the most efficient way to write 'for' loops in Matlab?
Is there an antonym for "spicy" or "hot" regarding food (NOT "seasoned" but "spicy")?
How can religions be structured in ways that allow inter-faith councils to work?
Is there a wealth gap in Boston where the median net worth of white households is $247,500 while the median net worth for black families was $8?
Polyhedra, Polyhedron, Polytopes and Polygon
How to get CPU-G to run on 18.04
How to kill my goat in Goat Simulator
How to judge a Ph.D. applicant that arrives "out of thin air"
Sea level static test of an upper stage possible?
Why did House of Representatives need to condemn Trumps Tweets?
Why did I lose on time with 3 pawns vs Knight. Shouldn't it be a draw?
What is the most common end of life issue for a car?
XMLFile parsing using file operations
XML Parser for CWhy can templates only be implemented in the header file?Parsing XML Encoded in UTF-8Return value for a << operator function of a custom string class in C++What is the “-->” operator in C++?How to override the ++ operator in C++ and then print the output using an overriden << operator?What are the basic rules and idioms for operator overloading?Error trying to use pthread on UbuntuGetting very long “No match for 'operator+'” error in C++C++: concatenate an enum to a std::stringGetting Error when reading file in string using C++Builder Project
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to write XML parser using file operations and I got the pointer of the XML file. I am trying to read character by character using fgetc function but it is not working.
std::string sFileName = "C:\Users\simple\Desktop\XMLFile.xml";
std::string sTempstring;
char cXML;
FILE *fptr;
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
const int bufSize = 412;
char* tempdata = new char[iLength]();
if (fptr != NULL)
int i = 0;
while ((cXML = fgetc(fptr)) != EOF)
cout << cXML;
i++;
sTempstring.append(tempdata);
cout << sTempstring.c_str();
else
cout << "File is empty";
getchar();
return 0;
Please let me know what mistake I am doing.
XML information i want to store that in some string by reading the xml file using file operations so i have written above function
c++
|
show 9 more comments
I am trying to write XML parser using file operations and I got the pointer of the XML file. I am trying to read character by character using fgetc function but it is not working.
std::string sFileName = "C:\Users\simple\Desktop\XMLFile.xml";
std::string sTempstring;
char cXML;
FILE *fptr;
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
const int bufSize = 412;
char* tempdata = new char[iLength]();
if (fptr != NULL)
int i = 0;
while ((cXML = fgetc(fptr)) != EOF)
cout << cXML;
i++;
sTempstring.append(tempdata);
cout << sTempstring.c_str();
else
cout << "File is empty";
getchar();
return 0;
Please let me know what mistake I am doing.
XML information i want to store that in some string by reading the xml file using file operations so i have written above function
c++
1
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
1
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06
|
show 9 more comments
I am trying to write XML parser using file operations and I got the pointer of the XML file. I am trying to read character by character using fgetc function but it is not working.
std::string sFileName = "C:\Users\simple\Desktop\XMLFile.xml";
std::string sTempstring;
char cXML;
FILE *fptr;
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
const int bufSize = 412;
char* tempdata = new char[iLength]();
if (fptr != NULL)
int i = 0;
while ((cXML = fgetc(fptr)) != EOF)
cout << cXML;
i++;
sTempstring.append(tempdata);
cout << sTempstring.c_str();
else
cout << "File is empty";
getchar();
return 0;
Please let me know what mistake I am doing.
XML information i want to store that in some string by reading the xml file using file operations so i have written above function
c++
I am trying to write XML parser using file operations and I got the pointer of the XML file. I am trying to read character by character using fgetc function but it is not working.
std::string sFileName = "C:\Users\simple\Desktop\XMLFile.xml";
std::string sTempstring;
char cXML;
FILE *fptr;
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
const int bufSize = 412;
char* tempdata = new char[iLength]();
if (fptr != NULL)
int i = 0;
while ((cXML = fgetc(fptr)) != EOF)
cout << cXML;
i++;
sTempstring.append(tempdata);
cout << sTempstring.c_str();
else
cout << "File is empty";
getchar();
return 0;
Please let me know what mistake I am doing.
XML information i want to store that in some string by reading the xml file using file operations so i have written above function
c++
c++
edited Mar 26 at 19:05
πάντα ῥεῖ
1
1
asked Mar 26 at 18:56
rajeerajee
55 bronze badges
55 bronze badges
1
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
1
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06
|
show 9 more comments
1
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
1
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06
1
1
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
1
1
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06
|
show 9 more comments
1 Answer
1
active
oldest
votes
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
fseek(fptr, 0L, SEEK_SET);
add fseek(fptr, 0L, SEEK_SET) specific location.
http://www.cplusplus.com/reference/cstdio/fseek/
Hope your study successfully done.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364450%2fxmlfile-parsing-using-file-operations%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
fseek(fptr, 0L, SEEK_SET);
add fseek(fptr, 0L, SEEK_SET) specific location.
http://www.cplusplus.com/reference/cstdio/fseek/
Hope your study successfully done.
add a comment |
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
fseek(fptr, 0L, SEEK_SET);
add fseek(fptr, 0L, SEEK_SET) specific location.
http://www.cplusplus.com/reference/cstdio/fseek/
Hope your study successfully done.
add a comment |
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
fseek(fptr, 0L, SEEK_SET);
add fseek(fptr, 0L, SEEK_SET) specific location.
http://www.cplusplus.com/reference/cstdio/fseek/
Hope your study successfully done.
fptr = fopen(sFileName.c_str(),"r");
fseek(fptr, 0L, SEEK_END);
long int iLength = ftell(fptr);
fseek(fptr, 0L, SEEK_SET);
add fseek(fptr, 0L, SEEK_SET) specific location.
http://www.cplusplus.com/reference/cstdio/fseek/
Hope your study successfully done.
answered Mar 26 at 19:57
Dahn ParkDahn Park
11 bronze badge
11 bronze badge
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364450%2fxmlfile-parsing-using-file-operations%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
"but it is not working" is a very vague problem description. Post a minimal reproducible example as required here please.
– πάντα ῥεῖ
Mar 26 at 18:59
XMLinfo: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
– rajee
Mar 26 at 19:00
That is the XML information i want to store that in some string by reading that xml file using file operations
– rajee
Mar 26 at 19:01
Post additional information in your question please.
– πάντα ῥεῖ
Mar 26 at 19:02
1
I suggest using an actual XML parsing library (plenty are available for C++), and not try to do this yourself with some home-made code. There are too many corner cases that can happen that your code could miss.
– PaulMcKenzie
Mar 26 at 19:06