I have a pretty large file that I need to parse in php, so I'm using xmlReader. I've just started playing around with xml and am having some problems....
Here is how the xml is structured...
<?xml version="1.0" encoding="utf-8"?>
<devices>
<os name="os1">
<device user_agent="uaValue1">
<device_name>name1</device_name>
<device_os>osValue1</device_os>
</device>
<device user_agent="uaValue2">
<device_name>name2</device_name>
<device_os>osValue2</device_os>
</device>
</os>
<os name="os2">
<device user_agent="uaValue3">
<device_name>name3</device_name>
<device_os>osValue5</device_os>
</device>
<device user_agent="uaValue4">
<device_name>name4</device_name>
<device_os>osValue4</device_os>
</device>
</os>
<manufacturer name="mf1">
<device user_agent="uaValue5">
<device_name>name5</device_name>
<device_os>osValue5</device_os>
</device>
<device user_agent="uaValue6">
<device_name>name6</device_name>
<device_os>osValue6</device_os>
</device>
</manufacturer>
<manufacturer name="mf2">
<device user_agent="uaValue7">
<device_name>name7</device_name>
<device_os>osValue7</device_os>
</device>
<device user_agent="uaValue8">
<device_name>name8</device_name>
<device_os>osValue8</device_os>
</device>
</manufacturer>
</devices>
I am trying to use the following function to read the xml (where $findby will pass os or manufacturer / $atr_value is the attribute name for the $findby value / $ua_str is the user agent).
function get_data($findby,$atr_value,$ua_str) {
$data['device_name'] = '';
$data['device_os'] = '';
$xml = new XMLReader;
$xml->open('devices.xml');
while($xml->read()) {
if ($xml->name == $findby) {
if ($xml->getAttribute('name') == $atr_value) {
while($xml->read()) {
if ($xml->name == "device") {
if ($xml->getAttribute('user_agent') == $ua_str) {
while($xml->read()) {
if ($xml->name == "device_name") {
$data['device_name'] = $xml->value;
}
if ($xml->name == "device_os") {
$data['device_os'] = $xml->value;
}
}
}
}
}
}
}
}
$xml->close();
return $data;
}
By echoing a few values here and there, it seems to pull data down to the user agent, but won't get the device_name or device_os.
Obviously, this is not working. I was thinking that the xml can't be structured that way which could be the problem and an easy fix. However on one of my previous versions, it pulled the data but it was from the wrong user agent. So I'm thinking it is something in how I am trying to pull the data with the xmlReader.
Does anyone have any thoughts on why this does not work? Thank you...
You're not checking the tag type in the outer while loop. XMLReader sends you opening tags, closing tags, tag content, and you need to handle at least some of those events.
In your outer loop, check $reader->nodeType == XMLReader::ELEMENT for an opening, XMLReader::END_ELEMENT for a closing, and XMLReader::TEXT for tag content. There are a lot of others too - see the PHP docs for this class (values 0-17).
I ended up just adding the elements I wanted as attributes and calling it like so to get the data...
function get_data($ua_str) {
$data = array();
$xml = new XMLReader;
$xml->open('devices.xml');
while($xml->read()) {
if ($xml->nodeType == XMLReader::ELEMENT && $xml->name == 'device') {
while($xml->read()) {
if ($xml->getAttribute('user_agent') == $ua_str) {
$data['device_mf'] = $xml->getAttribute('device_mf');
$data['device_os'] = $xml->getAttribute('device_os');
$data['device_name'] = $xml->getAttribute('device_name');
}
}
}
}
$xml->close();
return $data;
}
Related
I made three pictures pulled to stick with three others, and it was done successfully.
I wanted to add a reinforcement sound if the attachment was pulled and attached correctly, and another voice indicates dissatisfaction when the operation is not successful,
Problem: Booster still works on all images after a one-time success, and failure sound does not work.
That is, I was not able to correctly formulate symbols that control sounds from inside the library to work.
Please help solve the problem
In the code:
Names of images being pulled (r1, r2, r3), names of still images (m1, m2, m3), the sound of success mus1 and the sound of failure mus2
////////////////
stop();
r1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
r1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
r1.stopDrag();
if(r1.hitTestObject(m1))
{
r1.x=m1.x
r1.y=m1.y
}
else
{
r1.x=30.05
r1.y=155.95
}
}
r2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
function fl_ClickToDrag_2(event:MouseEvent):void
{
r2.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
r2.stopDrag();
if(r2.hitTestObject(m2))
{
r2.x=m2.x
r2.y=m2.y
///////////////Sound code for reinforcement
var musAPlay:Ahsant = new Ahsant();
var musA1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musA1Channel.stop();
musA1Channel = musAPlay.play();
}
else
{
r2.x=30.05
r2.y=249.4
//////////////Sound code not being successful
var musBPlay:noah = new noah();
var musB1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musB1Channel.stop();
musB1Channel = musBPlay.play();
}
}
r3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
function fl_ClickToDrag_3(event:MouseEvent):void
{
r3.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
function fl_ReleaseToDrop_3(event:MouseEvent):void
{
r3.stopDrag();
if(r3.hitTestObject(m3))
{
r3.x=m3.x
r3.y=m3.y
}
else
{
r3.x=30.05
r3.y=347.4
}
if(r1.hitTestObject(m1)&& r2.hitTestObject(m2) && r3.hitTestObject(m3))
gotoAndPlay (5)
}
//////////////////////////
I was able to solve the problem by replacing the stage with the name of the button, and after the code for the sound indicating for success, I put the following:
button.removeEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDrop);
button.removeEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
Where button is replaced with the custom name according to work
I have a xml in the following format.
<?xml version="1.0" encoding="UTF-8" standalone= "yes"?>
<rss>
<report name="rpt1">
<title>AAA</title>
<image></image>
<weblink></weblink>
<pdflink></pdflink>
<pdfsize></pdfsize>
</report>
<report name="rpt2">
<title>BBB</title>
<image>CCC</image>
<weblink>DDD</weblink>
<pdflink>EEE</pdflink>
<pdfsize>FFF</pdfsize>
</report>
</rss>
Now i want to iterate this xml and get the report node and from there get childnodes like title/pdflink/size etc which would be thru. looping using for loop. I want to use xmltextreader to accompalish this. I tried using while but i get only 1 loop after iterating. I dont know why. If thru for loop how do i iterate like,
for(loop when reader.element("reports)){} and then get the rest of the nodes and put them in an array or list or so. Once i get them stored in list i would want to dipaly them ina feed. which is a best way to do this? pls help.
In my case I was worried about the performance of loading a large document. What I have done is define a constructor on my objects to receive a XmlReader and hydrate - passing the reader back after it reaches a complete node.
This allows me to yield a populated object back as IEnumerable for each object as it's being read. Then I launch a new Task/Thread to handle processing that individual item and go back to processing the file.
private IEnumerable<Report> readReports(Stream reader)
{
var settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
var xmlReader = XmlReader.Create(reader, settings);
xmlReader.MoveToContent();
xmlReader.Read();
while (!xmlReader.EOF)
{
if (xmlReader.Name.ToUpper() == "report")
yield return new Report(xmlReader);
xmlReader.Read();
}
}
public Report(XmlReader reader) : this()
{
reader.MoveToContent();
if (reader.IsEmptyElement)
{
reader.Read();
return;
}
reader.Read();
while (!reader.EOF)
{
if (reader.IsStartElement())
{
switch (reader.Name.ToLower())
{
case "order_id":
this.OrderId = reader.ReadElementContentAsString();
break;
// abreviated the rest of the fields
default:
reader.Skip();
break;
}
}
else if (reader.Name.ToLower() == "report") //this watches for the end element of the container and returns after populating all properties
return;
}
}
I would definitly appreciate any feedback from the rest of the community, if there is a better approach or if there are any errors here please let me know.
I am trying to query against the table storage but I am getting the following error:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">One of the request inputs is not
valid.</message>
</error>
The code I use is as follows:
public IEnumerable<ShoppingItemEntity> Get(string shoppingRowKey) {
var ctx = getTableServiceContext();
var shoppingItems = ctx.CreateQuery<ShoppingItemEntity>(
Constants.TABLE_STORAGE_SHOPPING_ITEM_TABLE_NAME
).Where(x => x.PartitionKey == string.Empty && x.ShoppingId == shoppingRowKey).AsTableServiceQuery();
return shoppingItems.ToList();
}
private TableServiceContext getTableServiceContext() {
var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
return account.CreateCloudTableClient().GetDataServiceContext();
}
The strange thing here is that if I run the query without where clause, I get no errors:
public IEnumerable<ShoppingItemEntity> Get(string shoppingRowKey) {
var ctx = getTableServiceContext();
var shoppingItems = ctx.CreateQuery<ShoppingItemEntity>(
Constants.TABLE_STORAGE_SHOPPING_ITEM_TABLE_NAME
).AsTableServiceQuery();
return shoppingItems.ToList();
}
What do u think is the problem here?
There are articles here and here shows the similar experience you have had with Azure Table storage. When dealing with Azure Development Storage you really need to “convince” the table service provider that you know what you are doing by inserting some dummy entities.
I believe you sure like this article Azure Table Storage, what a pain in the ass.
Is there a way of listing which roles have access to a given page via code?
Example, I have a Testpage.aspx, and I wanted to list the roles allowed for this page when a user accesses the page. The URLAuthorizationManager must be able to find this out somehow, so there must be a way it knows what roles are configured in the webconfig for a page. or URL.
Here is the webconfig limiting the roles allowed to view this page.
<location path="Testpage.aspx">
<system.web>
<authorization>
<allow roles ="admin,sales" />
</authorization>
</system.web>
</location>
If I could find a solution, it would return "admin", "sales". Any one know how I can do this? Thanks
You can use the following code inside the page where you want to obtain the information.
var section = (AuthorizationSection)
WebConfigurationManager.GetSection("system.web/authorization");
var rules = section.Rules;
var allowedRoles = rules
.OfType<AuthorizationRule>()
.Where(r => r.Action == AuthorizationRuleAction.Allow)
.Select(r => r.Roles).First();
The reason for the call to First() is that .NET configuration is hierarchical. Suppose you have the following web site hierarchy and configuration:
/Default.aspx
/Web.config (<allow roles="admin,user" />)
/SubDir/
/Test.aspx
/Web.config (<allow roles="admin,other" />)
and you call the code above from Test.aspx.cs, then the property AuthorizationSection.Rules contains three items corresponding to respectively the configuration from /SubDir/Web.config, Web.config and machine.config. So the first element contains the roles admin and other.
My problem was very similar except I needed the ability to iterate through all of the
directories and related subdirectories and display allowed roles for each web page and folder directory. I was unable to use Ronald Wildenberg's solution because we're using .Net 2.0 so we don't have the Linq functionality.
His solution gave me the roadmap I needed. I also found help from from Microsoft's French IIS Support Team, Managing Forms Authentication Programmatically. I didn't want to rewrite the config files like they posted, rather we needed the ability to show the allowed roles for all directories and pages in our application. Our application is small. It has a total of 15 directories and less than 100 pages so this runs pretty quickly. Your mileage my vary depending on the size of your web site.
I started from the root directory and recursively searched for all webconfigs. I added them with their path to a string list then iterated through the list and called my ListRoles function. This function opens the web config and gets the location collection. Then it looks for the "system.web/authorization" like Ronald did. If it finds an authorization section it loops through the rules and excludes any inherited rules and focuses on AuthorizationRuleAction.Allow with associated roles:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Web.Configuration;
public void DisplayWebPageRoles()
{
//First walk the directories and find folders with Web.config files.
//Start at the root
DirectoryInfo baseDir = new DirectoryInfo(Server.MapPath("~/"));
//Do a little recursion to find Web.Configs search directory and subdirs
List<string> dirs = DirectoriesWithWebConfigFile(baseDir);
//Replace the folder path separator except for the baseDir
for (int i = 0; i < dirs.Count; i++)
{
dirs[i] = dirs[i].Replace(
baseDir.FullName.Replace("\\", "/"),
"/" + baseDir.Name + (i > 0 ? "/" : ""));
}
//Now that we have the directories, we open the Web.configs we
//found and find allowed roles for locations and web pages.
for (int i = 0; i < dirs.Count; i++)
{
//Display on page, save to DB, etc...
ListRoles(dirs[i]);
}
}
public List<string> DirectoriesWithWebConfigFile(DirectoryInfo directory)
{
List<string> dirs = new List<string>();
foreach (FileInfo file in directory.GetFiles("Web.config"))
{
dirs.Add(directory.FullName.Replace("\\","/"));
}
foreach (DirectoryInfo dir in directory.GetDirectories())
{
dirs.AddRange(DirectoriesWithWebConfigFile(dir));
}
return dirs;
}
private void ListRoles(string configFilePath)
{
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(configFilePath);
//Get location entries in web.config file
ConfigurationLocationCollection locCollection = configuration.Locations;
string locPath = string.Empty;
foreach (ConfigurationLocation loc in locCollection)
{
try
{
Configuration config = loc.OpenConfiguration();
//Get the location path so we know if the allowed roles are
//assigned to a folder location or a web page.
locPath = loc.Path;
if (locPath.EndsWith(".js")) //Exclude Javascript libraries
{
continue;
}
AuthorizationSection authSection =
(AuthorizationSection)config
.GetSection("system.web/authorization");
if (authSection != null)
{
foreach (AuthorizationRule ar in authSection.Rules)
{
if (IsRuleInherited(ar))
{
continue;
}
if (ar.Action == AuthorizationRuleAction.Allow
&& ar.Roles != null
&& ar.Roles.Count > 0)
{
for (int x = 0; x < ar.Roles.Count; x++)
{
//Display on page, save to DB, etc...
//Testing
//Response.Write(
// configFilePath + "/web.config" + ","
// + configFilePath + "/" + locPath + ","
// + ar.Roles[x] + "<br />");
}
}
}
}
}
catch (Exception ex)
{
//Your Error Handling Code...
}
}
}
From French IIS support Team blog
private bool IsRuleInherited(AuthorizationRule rule)
{
//to see if an access rule is inherited from the web.config above
//the current one in the hierarchy, we look at two PropertyInformation
//objects - one corresponding to roles and one corresponding to
//users
PropertyInformation usersProperty = rule.ElementInformation.Properties["users"];
PropertyInformation rolesProperty = rule.ElementInformation.Properties["roles"];
//only one of these properties will be non null. If the property
//is equal to PropertyValueOrigin.Inherited, the this access rule
//if not returned in this web.config
if (usersProperty != null)
{
if (usersProperty.ValueOrigin == PropertyValueOrigin.Inherited)
return true;
}
if (rolesProperty != null)
{
if (rolesProperty.ValueOrigin == PropertyValueOrigin.Inherited)
return true;
}
return false;
}
Use the Roles.GetAllRoles() method
http://msdn.microsoft.com/en-us/library/system.web.security.roles.getallroles.aspx
and here is an example where they list all roles:
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
First time here asking a question and still learning on how to format things better... so sorry about the format as it does not look too well.
I have started learning flex and picked up a book and tried to follow the examples in it. However, I got stuck with a problem. I have a jsp page which returns xml which basically have a list of products. I am trying to parse this xml, in other words go through products, and create Objects for each product node and store them in an ArrayCollection. The problem I believe I am having is I am not using the right way of navigating through xml.
The xml that is being returned from the server looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?><result type="success">
<products>
<product>
<id>6</id>
<cat>electronics</cat>
<name>Plasma Television</name>
<desc>65 inch screen with 1080p</desc>
<price>$3000.0</price>
</product>
<product>
<id>7</id>
<cat>electronics</cat>
<name>Surround Sound Stereo</name>
<desc>7.1 surround sound receiver with wireless speakers</desc>
<price>$1000.0</price>
</product>
<product>
<id>8</id>
<cat>appliances</cat>
<name>Refrigerator</name>
<desc>Bottom drawer freezer with water and ice on the door</desc>
<price>$1200.0</price>
</product>
<product>
<id>9</id>
<cat>appliances</cat>
<name>Dishwasher</name>
<desc>Large capacity with water saver setting</desc>
<price>$500.0</price>
</product>
<product>
<id>10</id>
<cat>furniture</cat>
<name>Leather Sectional</name>
<desc>Plush leather with room for 6 people</desc>
<price>$1500.0</price>
</product>
</products></result>
And I have flex code that tries to iterate over products like following:
private function productListHandler(e:JavaFlexStoreEvent):void
{
productData = new ArrayCollection();
trace(JavaServiceHandler(e.currentTarget).response);
for each (var item:XML in JavaServiceHandler(e.currentTarget).response..product )
{
productData.addItem( {
id:item.id,
item:item.name,
price:item.price,
description:item.desc
});
}
}
with trace, I can see the xml being returned from the server. However, I cannot get inside the loop as if the xml was empty. In other words, JavaServiceHandler(e.currentTarget).response..product must be returning nothing. Can someone please help/point out what I could be doing wrong.
My JavaServiceHandler class looks like this:
package com.wiley.jfib.store.data
{
import com.wiley.jfib.store.events.JavaFlexStoreEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class JavaServiceHandler extends EventDispatcher
{
public var serviceURL:String = "";
public var response:XML;
public function JavaServiceHandler()
{
}
public function callServer():void
{
if(serviceURL == "")
{
throw new Error("serviceURL is a required parameter");
return;
}
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleResponse);
loader.load(new URLRequest(serviceURL));
// var httpService:HTTPService = new HTTPService();
// httpService.url = serviceURL;
// httpService.resultFormat = "e4x";
// httpService.addEventListener(Event.COMPLETE, handleResponse);
// httpService.send();
}
private function handleResponse(e:Event):void
{
var loader:URLLoader = URLLoader(e.currentTarget);
response = XML(loader.data);
dispatchEvent(new JavaFlexStoreEvent(JavaFlexStoreEvent.DATA_LOADED) );
// var httpService:HTTPService = HTTPService(e.currentTarget);
// response = httpService.lastResult.product;
// dispatchEvent(new JavaFlexStoreEvent(JavaFlexStoreEvent.DATA_LOADED) );
}
}
}
Even though I refer to this as mine and it is not in reality. This is from a Flex book as a code sample which does not work, go figure.
Any help is appreciated.
Thanks
john
I just tried following code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="onComplete();">
<mx:Script>
<![CDATA[
import radekg.JavaServiceHandler;
private function onComplete():void {
var jsh:JavaServiceHandler = new JavaServiceHandler();
for each ( var node:XML in jsh.response.products.product ) {
trace( node.id.text() );
trace( node.cat.text() );
trace( node.name.text() );
trace( node.desc.text() );
trace( node.price.text() );
trace("---------------------------------------");
}
}
]]>
</mx:Script>
</mx:WindowedApplication>
And radekg/JavaServiceHandler.as which emulates your handler class:
package radekg
{
public class JavaServiceHandler
{
public var response:XML = <result type="success">
<products>
<product>
<id>6</id>
<cat>electronics</cat>
<name>Plasma Television</name>
<desc>65 inch screen with 1080p</desc>
<price>$3000.0</price>
</product>
<product>
<id>7</id>
<cat>electronics</cat>
<name>Surround Sound Stereo</name>
<desc>7.1 surround sound receiver with wireless speakers</desc>
<price>$1000.0</price>
</product>
<product>
<id>8</id>
<cat>appliances</cat>
<name>Refrigerator</name>
<desc>Bottom drawer freezer with water and ice on the door</desc>
<price>$1200.0</price>
</product>
<product>
<id>9</id>
<cat>appliances</cat>
<name>Dishwasher</name>
<desc>Large capacity with water saver setting</desc>
<price>$500.0</price>
</product>
<product>
<id>10</id>
<cat>furniture</cat>
<name>Leather Sectional</name>
<desc>Plush leather with room for 6 people</desc>
<price>$1500.0</price>
</product>
</products></result>;
}
}
And as a result I'm getting:
6
electronics
Plasma Television
65 inch screen with 1080p
$3000.0
---------------------------------------
7
electronics
Surround Sound Stereo
7.1 surround sound receiver with wireless speakers
$1000.0
---------------------------------------
8
appliances
Refrigerator
Bottom drawer freezer with water and ice on the door
$1200.0
---------------------------------------
9
appliances
Dishwasher
Large capacity with water saver setting
$500.0
---------------------------------------
10
furniture
Leather Sectional
Plush leather with room for 6 people
$1500.0
---------------------------------------
Your JavaServiceHandler.result points to the XML root tag so in other words, replace your:
for each (var item:XML in JavaServiceHandler(e.currentTarget).response.products..product )
with:
for each (var item:XML in JavaServiceHandler(e.currentTarget).response.products.product )
Hope that helps.
I'm, not exactly an XML / Flex whiz, but is this a typo?
for each (var item:XML in JavaServiceHandler(e.currentTarget).response..product )
Did you try
for each (var item:XML in JavaServiceHandler(e.currentTarget).response.result.products.product )
That's how I do it. Explicit, explicit, explicit.
Try looking at JavaServiceHandler(e.currentTarget).response with a debugger. If it IS the XML you're referring to, then your method of accessing product should work. So, it's likely that your Java backend returns not the XML you're expecting.
Try loading the same XML from a simple text file, or simply embed it into a string to make it even more simple:
[Embed (source="xmltest.xml")]
private var xmlTest:String;
And then initialize XML with a var xml:XML = new XML(xmlTest); and try trace(xml..product)
The root element in your XML is result. So you should have either
for each (var item:XML in JavaServiceHandler(e.currentTarget).response.products..product )
Yes, two dots - no typo there, or (if you know for sure you'll have only product elements):
for each (var item:XML in JavaServiceHandler(e.currentTarget).response.products.children() )
Because you didn't tidy up your XML, you mistook products element for the root, as it took some time for me to notice too. The moral of the story is: always tidy up your XML.
Assign static value for DATA_LOADED in JavaFlexStoreEvent.as
public static const DATA_LOADED:String="onDataLoaded"
I Think you are not created JAvaFlexStoreEVent Here I am Posted full class
package com.wiley.jfib.store.events
{
import flash.events.Event;
public class javaFlexStoreEvent extends Event
{
public static const DATA_LOADED:String="onDataLoaded";
public function javaFlexStoreEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
I see that you have commented out the use of http service. If you use this object and then specify the result data type of 'OBJECT', which you can access via the static variable 'HTTPService.RESULT_FORMAT_OBJECT'. This will then automatically parse your XML into objects for you. You can then use simple dot notation to access the data rather than looping over the XML.
Once you make this change, run the application using the debugger. Breakpoint your code at the result handler code and take a look at the result data. You should see that your XML has been parsed into an ArrayCollection of ObjectPoxy objects, which you can then loop over and map to your own objects for use in your application.
The benefit here is that the internal parser will handle namespaces, and most other variations of XML you throw at it, without you having to worry about it.
You can lose some performance with large data sets, but of course that only depends on how efficient you can write your own parsing code to be.