C++ 프로그램에서 XML 파일을 읽으려고합니다. 내가 XML 파일을보고 다음과 같이 읽어보십시오 지금C++ 프로그램에서 XML 파일 읽기
<?xml version="1.0" encoding="utf-8"?>
<myprogram>
<configuration>
<window>
<height> 300 </height>
<width> 500 </width>
</window>
</configuration>
</myprogram>
: 정말 일반적으로
ifstream in("mydata.xml");
//ignore the <?xml line
in.ignore(200, '\n');
//i know that the first value i want is the window height so i can ignore <myprogram> <configuration> and <window>
//ignore <myprogram>
in.ignore(200, '\n');
//ignore <configuration>
in.ignore(200, '\n');
//ignore <window>
in.ignore(200, '\n');
string s; int height;
//okay, now i have my height
in >> s >> height;
이 나쁜 생각처럼 보인다 XML 파일은 다음과 같이 보입니다 XML 파일을 수정하는 방법을 제한합니다. 위의 해결 방법은 매우 수동적이며 XML의 내용이 변경되면 XML을 읽는 전체 방법을 변경해야하는 것으로 보입니다.
더 좋은 방법이 있나요?
나는 C++을 사용하지 않았다. 그래서 나는 C++을위한 하나의 이름을 모르지만 xml 파서를 google에 넣었다. 나는 당신이 뭔가를 찾을 것이라고 확신한다. – Dan675