Home » U++ Library support » U++ Core » XML parsing error
| XML parsing error [message #16836] |
Wed, 16 July 2008 13:23  |
TeCNoYoTTa
Messages: 138 Registered: July 2008 Location: Egypt
|
Experienced Member |
|
|
hello
i am sorry if my Question was boring for you to solve but i dont know what is the proplem
i made this structer and class
struct message
{
String title;
String body;
String popup;
String link;
String attachment;
};
class news
{
private:
message Current_Message;
String sender;
public:
news(XmlParser Xml_File)
{
while(!Xml_File.IsTag())
Xml_File.Skip();
Xml_File.PassTag("root");
while(!Xml_File.IsEof())
{
if(Xml_File.Tag("new"))
{
if(Xml_File.Tag("message"))
{
while(!Xml_File.End())
{
if(Xml_File.Tag("title"))
Current_Message.title = Xml_File.ReadText();
if(Xml_File.Tag("body"))
Current_Message.body = Xml_File.ReadText();
if(Xml_File.Tag("popup"))
Current_Message.popup = Xml_File.ReadText();
if(Xml_File.Tag("link"))
Current_Message.link = Xml_File.ReadText();
if(Xml_File.Tag("attachment"))
Current_Message.attachment = Xml_File.ReadText();
else
{
Xml_File.Skip();
continue;
}
Xml_File.PassEnd();
}
}
else if(Xml_File.Tag("sender"))
{
sender = Xml_File.ReadText();
}
else
Xml_File.Skip();
}
}
}
message GetMessage()
{
return Current_Message;
}
String GetSender()
{
return sender;
}
};
this class takes xmlparser as constructor
and put the data in the private variables
when i call it from here
CISNotifier::CISNotifier() //project constructer
{
CtrlLayout(*this, "Window title");
HttpClient client;
client.URL("http://cisclub.com/tecno/bta3/XML.xml");
String content;
content = client.ExecuteRedirect();
XmlParser p(content);
news obj(p);
message m = obj.GetMessage();
String s = obj.GetSender();
static_text.SetText(s);
}
the program links but it dont work :S :S
please help me
you can check the xml file as the link is in the code
|
|
|
|
|
|
|
|
| Re: XML parsing error [message #16849 is a reply to message #16847] |
Thu, 17 July 2008 00:09   |
bytefield
Messages: 210 Registered: December 2007
|
Experienced Member |
|
|
You forgot to check for some tags...
<timing>
<date>
<day>15</day>
<month>7</month>
</date>
<time>
<hours>19</hours>
<minutes>35</minutes>
</time>
</timing>
... and because of that you get in loop, check for EOF, than you check for "new" tag, after that you check for "message" tag but because the next tag is "timing" the else part get executed and there you check for "sender" and because the current tag isn't "sender" tag you skip to next tag. Now the current tag is "date" and you get to the begin of the loop. You check for "new" tag and because current tag is "date" that if never get executed and you cpu run that loop again and again.
Just go trough your program step by step and see what I've explained above.
Edit: | Quote: | but isn't this else case must prevent infinite loop ??
|
you should have an else case also for "new" tag.
cdabbd745f1234c2751ee1f932d1dd75
[Updated on: Thu, 17 July 2008 00:12] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: XML parsing error [message #16865 is a reply to message #16864] |
Thu, 17 July 2008 20:55  |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
|
I didn't have much luck on XmlNode, but once I got the parsing working I didn't give it another thought. I'll give it a go. Thanks.
|
|
|
|
Goto Forum:
Current Time: Tue Apr 28 13:34:40 GMT+2 2026
Total time taken to generate the page: 0.00898 seconds
|