npm 57
New Member
Here's the sample xml: - <?xml version="1.0" encoding="UTF-8"?>
-
<menu>
-
<entry>
-
<action>
-
Test
-
</action>
-
<title>
-
Test Menu Item 1
-
</title>
-
</entry>
-
<entry>
-
<action>
-
Test 2
-
</action>
-
<title>
-
Test Menu Item 2
-
</title>
-
</entry>
-
</menu>
And here's the php code: - <?php
-
$dom = new DOMDocument();
-
$dom->load("menu.xml");
-
$menu = new domxpath($dom);
-
foreach($menu->query("//menu/entry") as $entry) {
-
echo "Action is: " . $menu->query('.//action',$entry)->item(0)->nodeValue;
-
echo "Title is: " . $menu->query('.//title',$entry)->item(0)->nodeValue;
-
}
-
?>
So why, when I view the page, do I get this error: Parse error: parse error, expecting `','' or `';'' in /home/httpd/vhosts/csnradio.com/www/test/2.php on line 6
I'm really clueless as to why this would happen because there are tutorials all over the place that are quite similar to this.
Thanks in advance!
18 1589 code green 1,726
Recognized Expert Top Contributor
You have a basic syntax error, that is all.
The error mesage points to where the error is (possibly the line above), which is line 6.
It is not obvious in the code supplied
Markus 6,050
Recognized Expert Expert
Code Green, I don't see it?
npm 57
New Member
I can't use SimpleXML because the server is running PHP 4.1.2. If I'm not mistaken, one needs version 5 to use SimpleXML, right?
I can see that the error is expecting a comma or a semicolon, but I don't know enough about php to know where they would go. Especially because the code is basically copied straight from a tutorial from someone who most likely had it working on their end.
Markus 6,050
Recognized Expert Expert
I'm struggling to spot the syntax error, also.
And you're using PHP4? Seriously? It's 2011!
npm 57
New Member
I know...
I don't see where the error is AND it's been almost 7 years since 5.0.0 was released!
code green 1,726
Recognized Expert Top Contributor
Can I stop what seems to be a misunderstandin g.
I don't see a syntax error. I don't even believe the error is in the code provided.
I thought npm was panicking because there was an xml parsing error.
I was trying to correct this assumption because the message is a php syntax error.
Now, what we need to see is the block of code, and 'line 6' pointing out.
Sorry for the confusion
npm 57
New Member
Would the error be a setting or something with the actual server or in that version of PHP (4.1.2)?
I just don't see where the "," or the ";" should go.
This might be something, but I don't know what:
I switched both of the "echo" commands in lines 6-7 to "print" and now I get this error: Parse error: parse error in /home/httpd/vhosts/csnradio.com/www/test/2.php on line 6
The error is in the same line, but it's different, right?
npm 57
New Member
Sorry, just for clarification, here's a visual of what I changed it to: - <?php
-
$dom = new DOMDocument();
-
$dom->load("xml.xml");
-
$menu = new DOMXPath($dom);
-
foreach($menu->query("//menu/entry") as $entry) {
-
print "Action is: " . $menu->query('.//action',$entry)->item(0)->nodeValue;
-
print "Title is: " . $menu->query('.//title',$entry)->item(0)->nodeValue;
-
}
-
?>
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ram Laxman |
last post by:
Hi all,
I have a text file which have data in CSV format.
"empno","phonenumber","wardnumber"
12345,2234353,1000202
12326,2243653,1000098
Iam a beginner of C/C++ programming.
I don't know how to tokenize the comma separated values.I used strtok
function reading line by line using fgets.but it gives some weird
behavior.It doesnot stripout the "" fully.Could any body have sample
code for the same so that it will be helfful for my...
|
by: |
last post by:
Hi,
I need to read a big CSV file, where different fields should be converted to
different types,
such as int, double, datetime, SqlMoney, etc.
I have an array, which describes the fields and their types. I would like
to somehow store a reference to parsing operations in this array
(such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc),
so I can invoke the appropriate one without writing a long switch.
|
by: Douglas Crockford |
last post by:
There is a new version of JSON.parse in JavaScript. It is vastly
faster and smaller than the previous version. It uses a single call to
eval to do the conversion, guarded by a single regexp test to assure
that it is safe.
JSON.parse = function (text) {
return
(/^(\s|]|"(\\|)*"|-?\d+(\.\d*)?(?\d+)?|true|false|null)+$/.test(text))
&& eval('(' + text + ')');
};
|
by: fyleow |
last post by:
I create a new Python file with the following using Wing IDE.
import feedparser
d = feedparser.parse("http://feedparser.org/docs/examples/atom10.xml")
print d.feed.title
I get this error when I debug.
AssertionError:
|
by: priyanka |
last post by:
Hi,
I was wondering if we could parse or do something in the executable(
whose source language was C). How can I use some scripting language
like perl/python to find out the information about the executable ? Is
it possible ?
Also, how does the compiler add inling to the program ? I know that
whenever it sees"inline" in front of the procedure name, it inlines it.
But if we give the -finline options, it inline all the procedures ? How
| |
by: gs |
last post by:
let say I have to deal with various date format and I am give format string
from one of the following
dd/mm/yyyy
mm/dd/yyyy
dd/mmm/yyyy
mmm/dd/yyyy
dd/mm/yy
mm/dd/yy
dd/mmm/yy
mmm/dd/yy
|
by: Perks |
last post by:
Hi.
I am trying to find out if it is possible to open a pdf file from
within PHP, and parse its contents in order to extract all form
fieldnames that might have been previously setup within the pdf
itself.
I want to find this out so that I can then generate a HTML form with
all required questions, which when submitted, will generate a fdf /
xfdf file, using the techniques from the following tutorial
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming.
FYI
Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
by: MonkeeSage |
last post by:
A quick question about how python parses a file into compiled
bytecode. Does it parse the whole file into AST first and then compile
the AST, or does it build and compile the AST on the fly as it reads
expressions? (If the former case, why can't functions be called before
their definitions?)
Thanks,
Jordan
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |