|
List Info
Thread: xmlReaderForFile Crashes when called recursivelly for different files.... Please need immediat
|
|
| xmlReaderForFile Crashes when called
recursivelly for different files....
Please need immediat |
  United States |
2007-03-12 16:30:54 |
|
Hi,
I am using the libXML to my load xml file. I am using the
windows version
of the libXML, which I downloaded from http://www.zlatkovic.com/libxml.en.html.
I call the same function recursively to load the parent and
alias xml files. I call this function
when an event occurs on a thread. The program crashes when I
call xmlReaderForFile
for an alias in the main xml file. I mean it loads the
parent xml successfully having the same alias xml,
but when it loads the alias for the main xml file it
crashes.. COULD SOMEONE PLEASE HELP ME..
Code Snippet
===========
void loadConfiguration(string urlStr)
{
xmlInitParser();
xmlTextReaderPtr
reader = NULL;
// XML_PARSE_NOCDATA, docs say it merges CDATA into #text.
reader = xmlReaderForFile(urlStr.c_str(),
NULL, XML_PARSE_NOENT | XML_PARSE_NOCDATA);
if (reader)
{
int
ret = xmlTextReaderRead(reader);
if
(ret == 1)
{
processNode(reader);
xmlChar* parentURI = getAttribute(reader,
(xmlChar*)"parent");
if (loadParentAlso
&& parentURI)
{
_parentConfigName = string((const char*)parentURI);
loadConfiguration(_parentConfigName));
}
xmlChar* aliasURI = getAttribute(reader,
(xmlChar*)"alias");
if (loadParentAlso
&& parentURI)
{
_aliasName = string((const char*)parentURI);
loadConfiguration(_aliasName));
}
}
}
xmlFreeTextReader(reader);
}
void
loadConfig(void *pData)
{
loadConfiguration("sampleApp.xml");
}
int
_tmain(int argc,
_TCHAR* argv[])
{
loadConfiguration("sampleApp.xml");
_beginthread(
loadConfig, 0, NULL );
getch();
return 0;
}
|
| How do you detect if a xml file has a
root node?? |
  United States |
2007-03-23 09:55:59 |
|
Hi,
I have an xml file of the below format.
<!—some comment
generated.." -->
<Node1>data</Node1>
How do I detect if the file has a root node or not?
I mean how do I make the difference between the below xml file
and the above xml file.
<!—some comment generated.." -->
<RootNode>
<Node1>data</Node1>
</RootNode>
I need to know it before parsing the whole file,
as I need to avoid the root node when I load the xml file.
So if the file is in the first format then I get wrong
results..
regards,
Jayashree
|
| Re: How do you detect if a xml file has
a root node?? |

|
2007-03-23 10:19:53 |
On Fri, Mar 23, 2007 at 10:55:59AM -0400, Kali, Jayashree
wrote:
> How do I detect if the file has a root node or not?
An XML file has one and only one root node, by definition,
http://www.
w3.org/TR/REC-xml/#NT-document
> I mean how do I make the difference between the below
xml file and the
> above xml file.
>
> <!-some comment generated.." -->
>
> <RootNode>
>
> <Node1>data</Node1>
>
> </RootNode>
There is still only one root node here,
> I need to know it before parsing the whole file,
I don't think you can, and I feel some confusion
Daniel
--
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine http://rpmfind.net/
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
|
|
| Re: How do you detect if a xml file has
a root node?? |
  Switzerland |
2007-03-23 10:40:34 |
> Hi,
>
>
>
> I have an xml file of the below format.
>
>
>
> <!-some comment generated.." -->
>
> <Node1>data</Node1>
>
>
>
> How do I detect if the file has a root node or not?
This file HAS a root node, it's called "Node1"
>
> I mean how do I make the difference between the below
xml
> file and the above xml file.
>
>
>
> <!-some comment generated.." -->
>
> <RootNode>
>
> <Node1>data</Node1>
>
> </RootNode>
The root node have different names. On your first example,
it was
"Node1", and now it is "RootNode"
> as I need to avoid the root node when I load the xml
file.
Why? You can just ignore (or not) the first node after you
have parsed
the file...
Best regards
Andreas
--
Andreas Tscharner
andreas.tscharner metromec.ch
------------------------------------------------------------
------------
And the beast shall come forth surrounded by a roiling cloud
of
vengeance. The house of the unbelievers shall be razed and
they shall be
scorched to the earth. Their tags shall blink until the end
of days.
-- The Book of
Mozilla 12:10
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|