473,323 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Using XMLReader and getting a bit stuck

nathj
938 Expert 512MB
Well, the time has come for me to ask another question, I hope someone can help.

Here's the deal, I need to read a specific node from an XML message that is stored in a string. I figure XMLReader is the way to go.

I know that the node in question will contain either 'True' or 'False' which is perfect for my project.

Here's my code
Expand|Select|Wrap|Line Numbers
  1. $this->lcNZResponse    =    $loRequest->getResponseBody(); 
  2.  
  3.         $loXMLReader        =    new XMLReader() ;
  4.         $loXMLReader->xml($this->lcNZResponse) ;
  5.         $lcTestString        =    $loXMLReader->getAttribute("Message") ;
  6.         if(strToLower($lcTestString) == "true")
  7.         {    
  8.             $llReturn = true ;
  9.         }                      
  10.         return $llReturn ;
  11.  
I know the response has a node in it called 'Message' but I can't seem to get the value out of it.

I have run the return through intVal() which for true should return 1, but even when I know the XML node contains 'True' the return is always false.

I hope that makes sense, and I hope someone can help me.

Cheers
nathj
Dec 2 '08 #1
6 1419
Markus
6,050 Expert 4TB
Wish I could be of help, but I can't! Never used XMLReader, and looking at it's documentation, I can see why people wouldn't: there's barely any documentation!

Maybe someone else will be of service.
Dec 2 '08 #2
nathj
938 Expert 512MB
@Markus
That part is a bit of a pain. do you have any alternative suggestions?

Cheers
nathj
Dec 2 '08 #3
nathj
938 Expert 512MB
Well, I would really like to use the XMLReader stuff as it seems the proper way to do things. But the documentation baffles me and I can't get it to work. so I have resorted to testing the XML like a simple string. Using strpos() I am able to determine if the bit I want is there.

It may be crude, it may not be transferable but at present it works and that's my main aim.

If anyone does know how to use the XMLReader stuff then please let me know, I hate using a fudge and that's what my solution feels like.

Cheers
nathj
Dec 2 '08 #4
Dormilich
8,658 Expert Mod 8TB
you could use SimpleXML (so you can use XPath).

regards
Dec 2 '08 #5
nathj
938 Expert 512MB
I nice idea, I'll have a play around with that as it could make the code much more transferable - always good when you work on multiple projects.
Dec 2 '08 #6
Dormilich
8,658 Expert Mod 8TB
note: SimpleXML is of no use when you have namespaces around (well if I remember right) then you have to use DOMDocument or related.

regards
Dec 2 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bob Rosen | last post by:
My message concerns a sample application that I took verbatim from the book titled "SAMS Teach Yourself Visual Basic.NET Web Programming in 21 days". It consists of a web page that takes the names...
0
by: kinryuu | last post by:
I am setting up an XmlReader in .NET 2.0 beta2. I'm trying to migrate away from the now deprecated XmlValidatingReader. The XML files I'm reading have an in-line schema. I'm noticing several...
0
by: Bob Rosen | last post by:
My message concerns a sample application that I took verbatim from the book titled "SAMS Teach Yourself Visual Basic.NET Web Programming in 21 days". It consists of a web page that takes the names...
0
by: kinryuu | last post by:
I am setting up an XmlReader in .NET 2.0 beta2. I'm trying to migrate away from the now deprecated XmlValidatingReader. The XML files I'm reading have an in-line schema. I'm noticing several...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.