草庐IT

php反序列化

全部标签

PHP - 字符串无法解析为 XML

这个问题在这里已经有了答案:Reference-WhatdoesthiserrormeaninPHP?(38个答案)关闭8年前。我目前正在使用以下代码,但没有返回结果:itemas$item){$title=$item->title;}echo$title;?>XML代码:AppleFruitAppleTheappleisthepomaceousfruitoftheappletree,Malusdomesticaoftherosefamily.Itisoneofthemostwidelycultivatedtreefruits,andthemostwidelyknownoftheman

java - 使用 Jackson 序列化 xml 使用不带注释的属性

我目前正在使用Jackson编写一些代码以将遗留POJO序列化为XML,但我需要使用属性而不是子元素对它们进行序列化。有没有办法在不向遗留类添加注释的情况下使用Jackson来做到这一点? 最佳答案 IsthereawaytodothisusingJacksonwithoutaddingannotationstothelegacyclasses?你可以尝试使用Mix-injackson的注释。通过这种方式,您可以保留您的遗留类,同时您将享受注释功能。就是这样。Person.classclassPerson{privateString

php - 使用 unset() 删除 XML 中的节点; PHP/simplexml_load_file

我正在尝试使用unset()通过PHP删除XML中的节点,但无法弄清楚这里发生了什么。它似乎无法正常工作,我在这里看到了很多其他类似性质的问题,但它们似乎并没有直接解决这个问题。这是我的XML的样子:TestName1test@test.comTestName2anotherone@test.comTestName3我正在使用的循环是这样的:url='data/users.xml';$xml=simplexml_load_file($url);foreach($xml->useras$theUser){if($theUser->email[0]=="test@test.com"){ec

c# - 在 C# 中反序列化多个具有相同名称的 XML 元素

我正在尝试解析此XML响应:BOSTONLOGANINTERNATIONAL,MA,UnitedStates(KBOS)42-22N071-01W54MFeb11,2015-11:54AMEST/2015.02.111654UTCfromtheN(010degrees)at17MPH(15KT)gustingto26MPH(23KT):02mile(s):0overcast19.9F(-6.7C)Windchill:5F(-15C):112.9F(-10.6C)73%30.08in.Hg(1018hPa)Success如您所见,“Wind”元素出现了两次,这让我很为难,因为我显然不能保

php - 解析器错误 : XML declaration allowed only at the start of the document

我有一个xml文件,其中包含如下多个声明Stefan42Shirt3000Damon32Jeans4000当我尝试加载xml时$data=simplexml_load_file("testdoc.xml")ordie("Error:Cannotcreateobject");然后它给了我以下错误Warning:simplexml_load_file():testdoc.xml:11:parsererror:XMLdeclarationallowedonlyatthestartofthedocumentinC:\xampp\htdocs\crea\services\testxml.phpo

php - 如何使用 PHP 检查 XML 标记是否为空?

如果我的XML文件的内容是:我正在使用$obj=simplexml_load_file($filepath)所以文件内容存储在$obj中。如您所见,结果标签是空的,没有文本或属性。如何检查结果标签是否为空?我考虑过这样做if(empty($obj->results))但我认为这不是正确的语法。 最佳答案 Asyoucansee,theresultstagisempty,ithasnotextorattributes.HowcanIcheckiftheresultstagisempty?在XML中,一个元素被认为是emptybydef

php - 在 php 中解析 xml

我有一个包含这样内容的XML提要ExcelentecasadedospisosencondominioenlaurbanizaciónSantaMariaDeVillaClub,enCarabayllo,conunAT:92m2yunAC:113m2,cuentacon3iluminadashabitaciones,3baños,cochera,deestreno,conáreasverdes,piscina,canchadefútbol,salonesparaactividades.¡Paramásinformacióncontactarseconnuestrosagente!ID:

php - 在json中ajax请求后获取值

我在收到ajax请求后无法获取我的json。当用户单击提交按钮时,我的ajax请求会检查值是否正确。我想以json格式返回错误的字段,然后在回调函数中返回。但我不知道该怎么做。这是我调用ajax的地方:$(document).ready(function(){$('#submit_button_essai').click(function(){$("td").eq(2).css("background-color","red");$.post("ajax_insert_essai.php",{arr:data_essai},insert_essai_callback);});});这是

java - 序列化和反序列化 Joda DateTime 对象

我已经开始将一个项目从使用JavaStandardDate迁移到JodaDateTime。我的项目使用XML序列化将对象保存到XML文件。在这种特殊情况下,我有一个具有DateTime属性的Item类。有时,我正在初始化对象,包括像这样的DateTime属性:Itemitem=newItem();item.setIdSearchCriteria(this.searchCriteria.getId());item.setUrl(fullUrl);item.setTitle(itemTitle);item.setDateTime(newDateTime());我使用XMLEncoder通过

c# - 在 C# 中,我无法将 XML 反序列化为对象

我已经查看了此处与此类似的各种问题,但无法让我的解决方案发挥作用。我正在使用VisualStudio2015社区构建WPF项目。我从我的后端API获取xml,我试图将它转换成C#对象,但我无法让它工作。这是xml这是类usingSystem.Xml.Serialization;namespaceCasechek.Kiosk{[XmlRoot("response")]publicclassComputerSettingResponse{[XmlElement("computer_setting")]internalComputerSettingSettings{get;set;}}int