XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 1st, 2002, 10:16 PM
coredumped coredumped is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 149 coredumped User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 49 m 47 sec
Reputation Power: 8
Help with XML DOM? (XML Newbie)

Now that I've thought of a potential practical use for XML, I'm actually trying to implement it.

I've read through (skimmed, really) the PHP & XML articles on devshed, in the XML section... and I've been playing around with using the XML DOM, but have a few questions.

My XML document looks something like this:

Code:
<?xml version="1.0"?>
<SITE>
  <SECTION1>
    <PAGE1>This is the first page of section 1.</PAGE1>
    <PAGE2>This is the second page of section 1.</PAGE2>
    <PAGE3>This is the third page of section 1.</PAGE3>
  </SECTION1>
  <SECTION2>
    <PAGE1>This is the first page of section 2.</PAGE1>
  </SECTION2>
</SITE>


Now, I'm using the DOM to extract the root, and then list all of the children of the root. However, what's happening is that even though I have 2 children of the 'SITE' node, my code is reporting that there are more. I've checked the type for these other nodes, and they say they're text objects, but I can't figure out what they are.

Here's my code:
PHP Code:
 $xmlFile "C:\\My Documents\\XML\\xmldoc.xml";

  
$xmlDoc xmldocfile($xmlFile);

  
$docRoot $xmlDoc->root();

  print(
"The document root tag is: <i>" $docRoot->name "</i><br><br>\n");

  
$docChildren $docRoot->children();

  print(
"There are <b>" sizeof($docChildren) . "</b> children to the Document Root Tag.<br>\n");

  print(
"<UL>\n");

  foreach(
$docChildren as $currChild)
  {
    if (
$currChild->type == 1)
      print(
"<LI> Type: " $currChild->type " | " $currChild->name);
    else if (
$currChild->type == 3)
      print(
"<LI> Type: " $currChild->type " | " $currChild);
  }

  print(
"</UL>\n"); 


The output looks like:

Warning: Unexpected character in input: ' ' (ASCII=11) state=1 in c:\my documents\xml\testxml.php on line 45
The Document Root Tag is: SITE

There are 5 children to the Document Root Tag.
  • Type: 3 | Object
  • Type: 1 | SECTION1
  • Type: 3 | Object
  • Type: 1 | SECTION2
  • Type: 3 | Object

So my first question is, why am I getting that 'Unexpected character in input' error?
Secondly, what are those three other 'objects'? What are they used for?

Can anyone help me out?

Thanx,

- coredumped.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Help with XML DOM? (XML Newbie)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT