Note that there are some explanatory texts on larger screens.

plurals
  1. PORead a line from xml file using C++
    primarykey
    data
    text
    <p>My XML File has:</p> <p><strong>&lt; Package > xmlMetadata &lt; /Package ></strong></p> <p>I am searching for a tag in this file and the text between the starting and closing tags of this has to be printed on console. i.e. in this case I want xmlMetadata to be printed on the console. Similarly it should go further in the file and print again if it encounters another &lt; Package > tag in the same file.</p> <p>Here is my code but it is printing the contents of the whole file:</p> <pre><code>{ string line="&lt; Package &gt;"; ifstream myfile (xmlFileName); //xmlFileName is xml file in which search is to done if (myfile.is_open()) { while ( myfile.good() ) { getline (myfile,line); std::cout&lt;&lt;line&lt;&lt; endl; } myfile.close(); } else cout &lt;&lt; "Unable to open file"; } </code></pre> <p>Displaying below my whole xml:</p> <pre><code>&lt; ? xml version="1.0" ? &gt; &lt; fileStructure &gt; &lt; Main_Package &gt; File_Navigate &lt; /Main_Package &gt; &lt; Dependency_Details &gt; &lt; Dependency &gt; &lt; Package &gt; xmlMetadata &lt; /Package &gt; &lt; Header &gt; xmlMetadata.h &lt; /Header &gt; &lt; Header_path &gt; C:\Dependency\xmlMetadata\xmlMetadata.h &lt; /Header_path &gt; &lt; Implementation &gt; xmlMetadata.cpp &lt; /Implementation &gt; &lt; Implementation_path &gt; C:\Dependency\xmlMetadata\xmlMetadata.cpp &lt; /Implementation_path &gt; &lt; /Dependency &gt; &lt; Dependency &gt; &lt; Package &gt; xmlMetadata1 &lt; /Package &gt; &lt; Header &gt; xmlMetadata1.h &lt; /Header &gt; &lt; Header_path &gt; C:\Dependency\xmlMetadata\xmlMetadata1.h &lt; /Header_path &gt; &lt; Implementation &gt; xmlMetadata1.cpp &lt; /Implementation &gt; &lt; Implementation_path &gt; C:\Dependency\xmlMetadata\xmlMetadata1.cpp &lt; /Implementation_path &gt; &lt; /Dependency &gt; &lt; /Dependency_Details &gt; &lt; /fileStructure &gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload