&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Request&gt;  &lt;Id&gt;   here the first tag  was written into file followed by xml version, i need that need to write in next line. like below  &lt;?xml version="1.0" encoding="UTF-8"?&gt;  &lt;Request&gt;   &lt;Id&gt;   i Have use below code to write the xml into file,please help  TransformerFactory transformerFactory = TransformerFactory                 .newInstance();         Transformer transformer = transformerFactory.newTransformer();         DOMSource source = new DOMSource(document);         StreamResult result = new StreamResult(new File(                 Constants.xmlLocation                         + Constants.metaDataXmlFileName                         + format.format(calendar.getTime()) + ".xml"));          transformer.setOutputProperty(OutputKeys.INDENT, "yes");         transformer.setOutputProperty(                 "{http://xml.apache.org/xslt}indent-amount", "5");         transformer.transform(source, result);
27515
I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this?  String unformattedXml = "&lt;tag&gt;&lt;nested&gt;hello&lt;/nested&gt;&lt;/tag&gt;"; String formattedXml = new [UnknownClass]().format(unformattedXml);   Note: My input is a String. My output is a String.   (Basic) mock result:    &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;root&gt;   &lt;tag&gt;     &lt;nested&gt;hello&lt;/nested&gt;   &lt;/tag&gt; &lt;/root&gt;
12188
I'm making an app with a custom list in multiple languages.  Is there an easy way so that I only have to create the site columns, content type and list once? So I don't have to create them for each language?  My app will be in English, French and Dutch.  My lists elements.xml looks like this  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;     &lt;!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. --&gt;     &lt;ListTemplate         Name="List1"         Type="10000"         BaseType="0"         OnQuickLaunch="TRUE"         SecurityBits="11"         Sequence="410"         DisplayName="List1"         Description="My List Definition"         Image="/_layouts/15/images/itgen.png"/&gt;   &lt;Field       Name="Adres"       ID="{2a32d9eb-ad3b-4dbb-abba-66dd01ca7c6e}"       DisplayName="$Resources:Adres"       Type="Text"       Required="TRUE" /&gt;   &lt;Field       Name="Naampje"       ID="{ac47be45-2f43-4d16-9a06-162c85945ec9}"       DisplayName="$Resources:Naampje"       Type="Text"       Required="FALSE" /&gt;   &lt;Field     Name="Nickname"     ID="{6B0A2CD7-A7F9-41ca-B932-F3BEBB603793}"     DisplayName="$Resources:Bijnaam"     Type="Text"     Required="FALSE" /&gt;  &lt;/Elements&gt;   Well if i change my language in Sharepoint (Office 365) it's not changing the titles from dutch to the other languages i have added.
68167
I'm loading an XML document in my C# application with the following:  XDocument xd1 = new XDocument(); xd1 = XDocument.Load(myfile);   but before that, I do test to make sure the file exists with:  File.Exists(myfile);   But... is there an (easy) way to test the file before the XDocument.Load() to make sure it's a valid XML file?  In other words, my user can accidentally click on a different file in the file browser and trying to load, say, a .php file causes an exception.    The only way I can think of is to load it into a StreamWriter and simple do a text search on the first few characters to make sure they say "  Thanks!  -Adeena
71398
I am using XmlSerializer to write and read an object to xml in C#.  I currently use the attributes XmlElement and XmlIgnore to manipulate the serialization of the object.  If my xml file is missing an xml element that I require, my object still deserializes (xml -> object) just fine.   How do I indicate (preferably via Attributes) that a certain field is "required"?  Here is a sample method of what I am using currently:  [XmlElement(ElementName="numberOfWidgets")] public int NumberThatIsRequired {     set ...;     get ...; }   My ideal solution would be to add something like an XmlRequired attribute.     Also, is there a good reference for what Attributes are available to manipulate the behavior of XmlSerializer?
96177
Do you know of a JAXB setting to prevent standalone="yes" from being generated in the resulting XML?  &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
82746
i have a tiny little problem with xslt, js and html entities, eg. within a template:  &lt;script type="text/javascript"&gt;     &lt;xsl:value-of select="/some/node"/&gt;     for (var i = 0; i &amp;lt; 5; i++) {         //            ^^^ js error     } &lt;/script&gt;  &lt;script type="text/javascript"&gt;     &lt;xsl:value-of select="/some/node"/&gt;     for (var i = 0; i &lt; 5; i++) {         //            ^ xslt error     } &lt;/script&gt;  &lt;script type="text/javascript"&gt;     &lt;xsl:value-of select="/some/node"/&gt;     // &lt;![CDATA[     for (var i = 0; i &lt; 5; i++) {         //            ^ becomes &amp;lt;     }     // ]]&gt; &lt;/script&gt;   &lt;script type="text/javascript"&gt;     &lt;xsl:value-of select="/some/node"/&gt;     for (var i = 0; i &lt;xsl:value-of disable-output-escaping="yes" select="string('&amp;lt;')"/&gt; 5; i++) {         // works of course     } &lt;/script&gt;   does anyone have an idea where my problem could come from? i always thought the xslt processor would leave the content of a &lt;script/&gt; element unescaped when using the html output method ...  i run libxslt2 version 1.1.24 on OSX which was installed using macportsports ...
97833
I decided to use  as a logger for a new webservice project. Everything is working fine, but I get a lot of messages like the one below, for every log4net tag I am using in my web.config:     Could not find schema information for   the element 'log4net'...   Below are the relevant parts of my web.config:    &lt;configSections&gt;     &lt;section name="log4net"          type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt;   &lt;/configSections&gt;   &lt;log4net&gt;     &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;       &lt;file value="C:\log.txt" /&gt;       &lt;appendToFile value="true" /&gt;       &lt;rollingStyle value="Size" /&gt;       &lt;maxSizeRollBackups value="10" /&gt;       &lt;maximumFileSize value="100KB" /&gt;       &lt;staticLogFileName value="true" /&gt;       &lt;layout type="log4net.Layout.PatternLayout"&gt;         &lt;conversionPattern value="%date [%thread] %-5level: %message%newline" /&gt;       &lt;/layout&gt;     &lt;/appender&gt;     &lt;logger name="TIMServerLog"&gt;       &lt;level value="DEBUG" /&gt;       &lt;appender-ref ref="RollingFileAppender" /&gt;     &lt;/logger&gt;   &lt;/log4net&gt;   Solved:   Copy every log4net specific tag to a separate xml-file. Make sure to use .xml as file extension. Add the following line to AssemblyInfo.cs:   [assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlFile.xml", Watch = true)]    added:     Just a word of warning to anyone   follow the advice of the answers in   this thread. There is a possible   security risk by having the log4net   configuration in an xml off the root   of the web service, as it will be   accessible to anyone by default. Just   be advised if your configuration   contains sensitive data, you may want   to put it else where.     @wcm: I tried using a separate file. I added the following line to AssemblyInfo.cs  [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]   and put everything dealing with log4net in that file, but I still get the same messages.
51639
I am using .Net framework 2.0 / jQuery to make an Ajax call to a 2.0 web service. No matter what I set the contentType to in the ajax call, the service always returns XML. I want it to return Json!  Here is the call:        $(document).ready(function() {          $.ajax({             type: "POST",             url: "DonationsService.asmx/GetDate",             data: "{}",             contentType: "application/json; charset=utf-8",             dataType: "json",             success: function(msg) {               // Hide the fake progress indicator graphic.               $('#RSSContent').removeClass('loading');                // Insert the returned HTML into the &lt;div&gt;.               $('#RSSContent').html(msg.d);             }           });         });       Here is what the request header looks like in Fiddler:  POST /DonationsService.asmx/GetDate HTTP/1.1 x-requested-with: XMLHttpRequest Accept-Language: en-us Referer: http://localhost:1238/text.htm Accept: application/json, text/javascript, */* Content-Type: application/json; charset=utf-8 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; eMusic DLM/4; .NET CLR 2.0.50727) Host: localhost:1238 Content-Length: 2 Connection: Keep-Alive Pragma: no-cache   I have tried setting the contentType to 'text/json' and get the same results.  Here is the web service method:  &lt;WebMethod()&gt; _ Public Function GetDate() As String      'just playing around with Newtonsoft.Json     Dim sb As New StringBuilder     Dim sw As New IO.StringWriter(sb)     Dim strOut As String = String.Empty      Using jw As New JsonTextWriter(sw)         With jw             .WriteStartObject()             .WritePropertyName("DateTime")             .WriteValue(DateTime.Now.ToString)             .WriteEndObject()         End With         strOut = sw.ToString     End Using      Return strOut  End Function   and here is what it returns:  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;string xmlns="http://DMS.Webservices.org/"&gt;{"DateTime":"11/13/2008 6:04:22 PM"}&lt;/string&gt;   Does anyone know how to force the web service to return Json when I ask for Json?  Please don't tell me to upgrade to .Net Framework 3.5 or anything like that (I'm not that stupid). I need a 2.0 solution.
13425
I'm trying to write a blog post which includes a code segment inside a &lt;pre&gt; tag. The code segment includes a generic type and uses &lt;&gt; to define that type. This is what the segment looks like:  &lt;pre&gt;     PrimeCalc calc = new PrimeCalc();     Func&lt;int, int&gt; del = calc.GetNextPrime; &lt;/pre&gt;   The resulting HTML removes the &lt;&gt; and ends up like this:  PrimeCalc calc = new PrimeCalc(); Func del = calc.GetNextPrime;   How do I escape the &lt;&gt; so they show up in the HTML?
94370
Now, before you say it: I did Google and my hbm.xml file is an Embedded Resource.   Here is the code I am calling:  ISession session = GetCurrentSession(); var returnObject =  session.Get&lt;T&gt;(Id);   Here is my mapping file for the class:  &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;   &lt;class name="HQData.Objects.SubCategory, HQData" table="SubCategory" lazy="true"&gt;     &lt;id name="ID" column="ID" unsaved-value="0"&gt;       &lt;generator class="identity" /&gt;     &lt;/id&gt;      &lt;property name="Name" column="Name" /&gt;     &lt;property name="NumberOfBuckets" column="NumberOfBuckets"  /&gt;     &lt;property name="SearchCriteriaOne" column="SearchCriteriaOne" /&gt;      &lt;bag name="_Businesses" cascade="all"&gt;       &lt;key column="SubCategoryId"/&gt;       &lt;one-to-many           class="HQData.Objects.Business, HQData"/&gt;     &lt;/bag&gt;      &lt;bag name="_Buckets" cascade="all"&gt;       &lt;key column="SubCategoryId"/&gt;       &lt;one-to-many          class="HQData.Objects.Bucket, HQData"/&gt;     &lt;/bag&gt;    &lt;/class&gt; &lt;/hibernate-mapping&gt;   Has anyone run to this issue before?  Here is the full error message:   MappingException: No persister for:  HQData.Objects.SubCategory]NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName, Boolean throwIfNotFound)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:766 NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:752 NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default\DefaultLoadEventListener.cs:37 NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:2054 NHibernate.Impl.SessionImpl.Get(String entityName, Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1029 NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1020 NHibernate.Impl.SessionImpl.Get(Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:985 HQData.DataAccessUtils.NHibernateObjectHelper.LoadDataObject(Int32 Id)  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQData\DataAccessUtils\NHibernateObjectHelper.cs:42 HQWebsite.LocalSearch.get_subCategory()  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:17 HQWebsite.LocalSearch.Page_Load(Object sender, EventArgs e)  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:27 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436   Update, here's what the solution for my scenario was: I had changed some code and I wasn't adding the Assembly to the config file during runtime.
73330
I'm in the process of retreiving some data from a xml file, it is actually a SSIS package file (dtsx).  I've read about using xmllint, however I'm having a hard time retrieving what I want.  I'd like to ask some helps from folks here.  This is what my xml looks like:  &lt;?xml version="1.0"?&gt; &lt;DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts"   DTS:refId="Package"   DTS:CreationDate="7/22/2019 4:18:27 PM"   DTS:CreationName="Microsoft.Package"   DTS:CreatorComputerName="ADMIN-8DF005D47"   DTS:CreatorName="ADMIN-8DF005D47\Administrator"   DTS:DTSID="{8CCA1D42-642A-4932-AAEC-E02175A4B2DB}"   DTS:ExecutableType="Microsoft.Package"   DTS:LastModifiedProductVersion="15.0.2000.68"   DTS:LocaleID="1033"   DTS:ObjectName="HardestNestedWorkflow2"   DTS:PackageType="5"   DTS:VersionBuild="12"   DTS:VersionGUID="{FDD9B190-1A03-4A19-8794-FA86F4F46A93}"&gt;   &lt;DTS:Property     DTS:Name="PackageFormatVersion"&gt;8&lt;/DTS:Property&gt;   &lt;DTS:ConnectionManagers&gt;     &lt;DTS:ConnectionManager       DTS:refId="Package.ConnectionManagers[ADMIN-8DF005D47.AdventureWorks]"       DTS:CreationName="OLEDB"       DTS:DTSID="{A32A68DF-3D53-4057-AF80-1B8D524F82BC}"       DTS:ObjectName="ADMIN-8DF005D47.AdventureWorks"&gt;       &lt;DTS:ObjectData&gt;         &lt;DTS:ConnectionManager           DTS:ConnectionString="Data Source=ADMIN-8DF005D47;Initial Catalog=AdventureWorks;Provider=SQLNCLI11;Integrated Security=SSPI;Application Name=SSIS-HardestNestedWorkflow2-{A32A68DF-3D53-4057-AF80-1B8D524F82BC}ADMIN-8DF005D47.AdventureWorks;Auto Translate=False;" /&gt;       &lt;/DTS:ObjectData&gt;      &lt;!--snipped--&gt;      &lt;/DTS:ConnectionManager&gt;   &lt;/DTS:ConnectionManagers&gt; &lt;/DTS:Executable&gt;   I'm looking to get the value "8" out of this line  &lt;DTS:Property     DTS:Name="PackageFormatVersion"&gt;8&lt;/DTS:Property&gt;   so, what I did was to issue a command  xmllint --xpath "//*[local-name()='Executable']/*[local-ame()='Property']/text()" HardestNestedWorkflow2_latest.xml   .. and it was good, I was able to extract the value "8"  Now, I wanted to extract the value   Data Source=ADMIN-8DF005D47;Initial Catalog=AdventureWorks;Provider=SQLNCLI11;Integrated Security=SSPI;Application Name=SSIS-HardestNestedWorkflow2-{A32A68DF-3D53-4057-AF80-1B8D524F82BC}ADMIN-8DF005D47.AdventureWorks;Auto Translate=False;   I issued this statement  xmllint --xpath "//*[local-name()='Executable']/*[local-name()='ConnectionManagers']/*[local-name()='ConnectionManager']/*[local-name()='ObjectData']/*[local-name()='ConnectionManager']" HardestNestedWorkflow2_latest.xml   and it returned this   &lt;DTS:ConnectionManager DTS:ConnectionString="Data Source=ADMIN-8DF005D47;Initial Catalog=AdventureWorks;Provider=SQLNCLI11;Integrated Security=SSPI;Application Name=SSIS-HardestNestedWorkflow2-{A32A68DF-3D53-4057-AF80-1B8D524F82BC}ADMIN-8DF005D47.AdventureWorks;Auto Translate=False;"/&gt;   how can I omit the tags DTS:ConnectionManager DTS:ConnectionString?  I'm sorry I'm not much knowledgeable on using xmllint.  Thanks in Advance
68575
I have an input xml file like below INPUT FILE &lt;ReconSummary&gt; &lt;entryName&gt;Total Deep&lt;/entryName&gt; &lt;Code&gt;777&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;   &lt;ReconSummary&gt; &lt;entryName&gt;Total Saurav&lt;/entryName&gt; &lt;Code&gt;666&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;   &lt;ReconSummary&gt; &lt;entryName&gt;Total Ankur&lt;/entryName&gt; &lt;Code&gt;555&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;  I want to comment the tag if i find the pattern &quot;Total Deep&quot; so that the output file looks like below OUTPUT &lt;!--&lt;ReconSummary&gt; &lt;entryName&gt;Total Deep&lt;/entryName&gt; &lt;Code&gt;777&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;--&gt;   &lt;ReconSummary&gt; &lt;entryName&gt;Total Saurav&lt;/entryName&gt; &lt;Code&gt;666&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;   &lt;ReconSummary&gt; &lt;entryName&gt;Total Ankur&lt;/entryName&gt; &lt;Code&gt;555&lt;/Code&gt; &lt;License&gt;L&lt;/License&gt; &lt;Tran&gt;H20&lt;/Tran&gt; &lt;job&gt;1234&lt;/job&gt; &lt;/ReconSummary&gt;  Since i am new to shell scripting, can anyone help me out as to how i can apply this with the help of shell scripting?
25788
I have an XSD file that is encoded in UTF-8, and any text editor I run it through doesn't show any character at the beginning of the file, but when I pull it up in Visual Studio's debugger, I clearly see an empty box in front of the file.      I also get the error:   Data at the root level is invalid. Line 1, position 1.    Anyone know what this is?  Update: Edited post to qualify type of file. It's an XSD file created by Microsoft's XSD creator.
38806
The input in file field.html.twig is normally like this:  {% for item in items %} &lt;div{{ attributes }}&gt;{{ item.content }}&lt;/div&gt; {% endfor %}   And you get the output in HTML like this:  &lt;div&gt;&lt;img src="path/to/image/image.png" alt="my wonderful image"&gt;&lt;/div&gt;   But I want to add a class to img-tag. How do I receive the following output:  &lt;div&gt;&lt;img class="img-fluid" src="path/to/image/image.png" alt="my wonderful image"&gt;&lt;/div&gt;   I am looking for a solution like , but it is not working. Can anybody help?
27673
I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all:  1: On byte level, how does serialization know how to match serialized values with some class?  One of my problems right here is that I made a small test with ArrayList containing values "one", "two", "three". After serialization the byte array took 78 bytes which seems awfully lot for such low amount of information(19+3+3+4 bytes). Granted there's bound to be some overhead but this leads to my second question:  2: Can serialization be considered a good method for persisting objects at all? Now obviously if I'd use some homemade XML format the persistence data would be something like this  &lt;object&gt;     &lt;class="java.util.ArrayList"&gt;     &lt;!-- Object array inside Arraylist is called elementData --&gt;     &lt;field name="elementData"&gt;         &lt;value&gt;One&lt;/value&gt;         &lt;value&gt;Two&lt;/value&gt;         &lt;value&gt;Three&lt;/value&gt;     &lt;/field&gt; &lt;/object&gt;   which, like XML in general, is a bit bloated and takes 138 bytes(without whitespaces, that is). The same in JSON could be   {     "java.util.ArrayList": {         "elementData": [             "one",             "two",             "three"         ]     } }   which is 75 bytes so already slightly  smaller than Java's serialization. With these text-based formats it's of course obvious that there has to be a way to represent your basic data as text, numbers or any combination of both.  So to recap, how does serialization work on byte/bit level, when it should be used and when it shouldn't be used and what are real benefits of serialization besides that it comes standard in Java?
116963
Is there any way to access the &lt;compilation /&gt; tag in a web.config file?  I want to check if the "debug" attribute is set to "true" in the file, but I can't seem to figure out how to do it. I've tried using the WebConfigurationManager, but that doesn't seem to allow me to get to the &lt;compilation /&gt; section.  Update:  I know I could easily just load the file like an XML Document and use XPath, but I was hoping there was already something in the framework that would do this for me. It seems like there would be something since there are already ways to get App Settings and Connection Strings.  I've also tried using the WebConfigurationManager.GetSection() method in a few ways:    WebConfigurationManager.GetSection("compilation")// Name of the tag in the file WebConfigurationManager.GetSection("CompilationSection") // Name of the class that I'd expect would be returned by this method WebConfigurationManager.GetSection("system.web") // Parent tag of the 'compilation' tag   All of the above methods return null. I'm assuming there is a way to get to this configuration section since there is a class that already exists ('CompilationSection'), I just can't figure out how to get it.
4477
Let's say I have some XML like this  &lt;channel&gt;   &lt;item&gt;     &lt;title&gt;This is title 1&lt;/title&gt;   &lt;/item&gt; &lt;/channel&gt;   The code below does what I want in that it outputs the title as a string  $xml = simplexml_load_string($xmlstring); echo $xml-&gt;channel-&gt;item-&gt;title;   Here's my problem.  The code below doesn't treat the title as a string in that context so I end up with a SimpleXML object in the array instead of a string.  $foo = array( $xml-&gt;channel-&gt;item-&gt;title );   I've been working around it like this  $foo = array( sprintf("%s",$xml-&gt;channel-&gt;item-&gt;title) );   but that seems ugly.  What's the best way to force a SimpleXML object to a string, regardless of context?