473,466 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dealing with nested xml within nested xml within......

Hello all,
I don't need specific examples, but I'm trying to wrap my head around
parsing xml within xml and even further, not limiting how far someone
will nest xml. I'm already making great use of BeautifulSoup's
BeautifulStoneSoup to parse xml, but what do I do if I come across
something like this?

<random>
<li>This is a random response (once parsed)</li>
<li>
<random>
<li>This is a random response within a random response</li>
<li>
<random>
<li>This is a random response within a random response,
within another random response</li>
<li>Like above, this is another random response.</li>
</random>
</li>
</random>
</li>
</random>

Not knowing how far one will nest random responses, how would one
manage digging into xml like this? Right now I'm thinking about not
even going there. I would presently write scripts that would parse 3
or so levels deep, but no further. :P It would make an interesting
project, like an interactive adventure story.

Jul 9 '07 #1
2 1054
On Jul 9, 3:03 pm, Ultrus <ownthe...@gmail.comwrote:
Hello all,
I don't need specific examples, but I'm trying to wrap my head around
parsing xml within xml and even further, not limiting how far someone
will nest xml. I'm already making great use of BeautifulSoup's
BeautifulStoneSoup to parse xml, but what do I do if I come across
something like this?

<random>
<li>This is a random response (once parsed)</li>
<li>
<random>
<li>This is a random response within a random response</li>
<li>
<random>
<li>This is a random response within a random response,
within another random response</li>
<li>Like above, this is another random response.</li>
</random>
</li>
</random>
</li>
</random>

Not knowing how far one will nest random responses, how would one
manage digging into xml like this? Right now I'm thinking about not
even going there. I would presently write scripts that would parse 3
or so levels deep, but no further. :P It would make an interesting
project, like an interactive adventure story.
You'd probably write a function that called itself to parse something
like this. Unfortunately, I am not a recursion expert. You can read up
on it though:

http://www.freenetpages.co.uk/hp/ala...d/tutrecur.htm
http://pythonjournal.cognizor.com/py...ByAJChung.html

I haven't used Beautiful Soup, but I think you can use lxml or
ElementTree to get a tree object of the XML and then just iterate over
the tree.

Mike

Jul 9 '07 #2
You'd probably write a function that called itself to parse something
like this. Unfortunately, I am not a recursion expert. You can read up
on it though:

http://www.freenetpages.co.uk/hp/ala...ByAJChung.html
Ah! That's the termage I was looking for. Thanks much for the link. I
will research recursion.

Jul 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mark | last post by:
My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater to work just fine, as long as it's not...
2
by: mark | last post by:
(not sure if this is the correct group) My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater...
0
by: mark | last post by:
My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater to work just fine, as long as it's not...
2
card
by: card | last post by:
Hi everyone, I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes: #include...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.