Search Results

Search found 19495 results on 780 pages for 'xml parse'.

Page 11/780 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • c# Deserializing an element based on it's parent node's name

    - by daveharnett
    The XML I'm working with has the following structure: <fixture_statistics> <home_player_1 id="2306143" teamid="2"> <element_1>Some Data</element_1> <element_2>Some Data</element_2> </home_player_1> <home_player_2 id="2306144" teamid="2"> <element_1>Some Data</element_1> <element_2>Some Data</element_2> </home_player_2> </fixture_statistics> Now the code to deserialize it would normally look like this: [XmlRootAttribute("fixture_statistics", Namespace = "", IsNullable = false)] public class FixtureRoot { [XmlElement("home_player_1")] [XmlElement("home_player_2")] public List<FixtureStats> fixtures { get; set; } } public class FixtureStats { public string element_1; [XMLElement("element_2")] public string elementTwo; } Here's the question: I'd like the FixtureStats class to have a 'position' property which corrosponds to it's parent's element name (so the FixtureStat object corrosponding to home_player_1 would have position=1). Can this be done with the built-in serialization atrributes? If it's not possible, what's the cleanest workaround? Bear in mind that each document will have about 50 player elements, each with about 50 'child' data elements.

    Read the article

  • How do I match complete XML objects in a string?

    - by cyclotis04
    I'm attempting to find complete XML objects in a string. They have been placed in the string by an XmlSerializer, but may or may not be complete. I've toyed with the idea of using a regular expression, because it seems like the kind of thing they were built for, except for the fact that I'm trying to parse XML. I'm trying to find complete objects in the form: <?xml version="1.0"?> <type> <field>value</field> ... </type> My thought was a regex to find <?xml version="1.0"?><type> and </type>, but if a field has the same name as type, it obviously won't work. There's plenty of documentation on XML parsers, but they seem to all need a complete, fully-formed document to parse. My XML objects can be in a string surrounded by pretty much anything else (including other complete objects). hw<e>reR@lot$0fr@ndm&nchrs%<?xml version="1.0"?><type><field>...</field>...</type>@ndH#r$omOre!!>nuT6erjc?y!<?xml version="1.0"?><type><field>...</field>...</type>ty!=] A regex would be able to match a string while excluding the random characters, but not find a complete XML object. I'd like some way to extract an object, parse it with a serializer, then repeat until the string contains no more valid objects.

    Read the article

  • Extracting specific nodes from XML using XML::Twig

    - by pratz
    i was trying to extract a particular set of nodes from the following XML structure using XML::Twig, but have been stuck ever since. I need to extract the 'player' nodes from the following structure and do a string match/replace on each of these node values. <pep:record> <agency> <subrecord type="scout"> <isnum>123XXX (print)</isnum> <isnum>234YYY (mag)</isnum> </subrecord> <subrecord type="group"> </subrecord> </agency </record> I tried using the following code, but I get pointed to a hash reference rather than actual string. my $parser = XML::Twig->new(twig_handlers => { isnum => sub { print $_->text."::" }, }); foreach my $rec (split(/::/, $parser->parse($my_xml))) { if ($rec =~ m/print/) { ($print = $rec) =~ s/( \(print\))//; } elsif($rec =~ m/mag/) { ($mag = $rec) =~ s/( \(mag\))//; } }

    Read the article

  • PHP XML - Inserting a XML node at a specific location

    - by Blueboye
    Hi Guys, I want to insert a node with children at a specific location in the XML file. How do I do it? For eg. If I have an XML like: <myvalues> <image name="img01"> <src>test</src> </image> <image name="img02"> <src>test</src> </image> <image name="img03"> <src>test</src> </image> </myvalues> I want to insert: <image name="img11"> <src>test2</src> </image> between <image name="img01"> & <image name="img02">. How do I do this? I am using SimpleXML right now to read the XML. Thanks.

    Read the article

  • how do i parse an xml page to output its data pieces to the way i want?

    - by ida
    here is the page i want to parse (the api link i gave is just a dev test so its ok to be public) http://api.scribd.com/api?method=docs.getList&api_key=2apz5npsqin3cjlbj0s6m the output im looking for is something like this (for now) Doc_id: 29638658 access_key: key-11fg37gwmer54ssq56l3 secret_password: 1trinfqri6cnv3gf6rnl title: Sample description: k thumbnail_url: http://i6.scribdassets.com/public/images/uploaded/152418747/xTkjCwQaGf_thumbnail.jpeg page_count: 100 ive tried everything i can find on the internet but nothing works good. i have this one script <?php $xmlDoc = new DOMDocument(); $xmlDoc->load("http://api.scribd.com/api?method=docs.getList&api_key=2apz5npsqin3cjlbj0s6m"); $x = $xmlDoc->documentElement; foreach ($x->childNodes AS $item) { print $item->nodeName . " = " . $item->nodeValue; } ?> its output comes out like this: #text = resultset = 29638658 key-11fg37gwmer54ssq56l3 1trinfqri6cnv3gf6rnl Sample k http://i6.scribdassets.com/public/images/uploaded/152418747/xTkjCwQaGf_thumbnail.jpeg DONE 100 29713260 key-18a9xret4jf02129vlw8 25fjsmmvl62l4cbwd1vq book2 description bla bla http://i6.scribdassets.com/public/images/uploaded/153065528/oLVqPZMu3zhsOn_thumbnail.jpeg DONE 7 #text = i need major help im really stuck and dont know what to do. please please help me. thnx

    Read the article

  • xml schema and using a choice as the document root

    - by mikey
    I have a bit of a newbie xml schema question. I believe the answer is that what I need to do is not possible with schema, but I'd like to be sure. The problem is that I have a webservice that returns a response with one type of root element on success (say <Response), and on a complete failure, returns a document with a different root element (say, <Exception). So, basically, two completely different documents: <Response......</Response OR <Exception....</Exception Is it possible to describe these two different documents with one schema document? It's like I want a choice as the first element under the schema element -- but that isn't valid syntax. I've tried a couple of variants that parse as valid xsd, but don't validate the documents. Any suggestions? Or is this simply not possible? Thanks very much in advance -- m

    Read the article

  • Parse XML tree with no id using LINQ to XML

    - by Danny
    Requirement I want to read a XML tree, fill my objects with encountered attributes and after every run a method (insert it into my db). The amount of parents is not specified, also the order is not specified, it could be, address-death-death-address-address for example Input file Overview: <Root> <Element> <Element2> <Parent> <Child> <Grandchild> <Grandchild> </Child> </Parent> </Element2> </Element1> </Root> Full example: <?xml version="1.0" encoding="utf-8" ?> <Root> <Element1> <Element2> <Parent> <Child> <Grandchild> <number>01</number> <name>Person</name> <Rows> <Row> <number>0110</number> <name>ID</name> <value>123456789</value> </Row> </Rows> </Grandchild> <Grandchild> <number>08</number> <name>Address</name> <Rows> <Row> <number>1110</number> <name>street</name> <value>first aveneu</value> </Row> <Row> <number>1120</number> <name>streetnumber</name> <value>345</value> </Row> <Row> <number>1130</number> <name>zip</name> <value>2938PS</value> </Row> <Row> <number>1160</number> <name>country</name> <value>Germany</value> </Row> </Rows> </Grandchild> </Child> </Parent> <Parent> <Child> <Grandchild> <number>01</number> <name>Person</name> <Rows> <Row> <number>0110</number> <name>ID</name> <value>987654321</value> </Row> </Rows> </Grandchild> <Grandchild> <number>06</number> <name>Death</name> <Rows> <Row> <number>0810</number> <name>date</name> <value>2012-01-03</value> </Row> <Row> <number>0820</number> <name>placeOfDeath</name> <value>attic</value> </Row> <Row> <number>0830</number> <name>funeral</name> <value>burrial</value> </Row> </Rows> </Grandchild> </Child> </Parent> </Element2> </Element1> </Root> Desired result After encounter of parent determine type of grandchild (number 6 is death number 8 is address) Every parent has ALWAYS grandchild number 1 'Person', the second grandchild is either death or address. reading first parent Person person = new Person(); person.ID = value; <--- filled with 123456789 person.street = value; <--- filled with first aveneu person.streetnumber = value; <--- filled with 345 person.zip = value; <--- filled with 2938PS person.country = value; <--- filled with germany person.DoMethod(); // inserts the value in db Continue reading next parent. Person person = new Person(); person.ID = value; <--- filled with 987654321 person.date = value; <--- filled with 2012-01-03 person.placeOfDeath = value; <--- filled with attic person.funeral = value; <--- filled with burrial person.DoMethod(); // insert the values in db Continue reading till no parents found EDIT: how do I target the name element of the second grandchild for every child? Like address or death Code/Credit I got no further then this, with help of Daniel Hilgarth: Linq to XML (C#) parse XML tree with no attributes/id to object The XML tree has changed, and I am really stuck.. in the meantime I try to post new working code...

    Read the article

  • Announcing RSS feeds of Microsoft All-In-One Code Framework code samples

    - by Jialiang
    Today, we are not only announcing Sample Browser v2 CTP, but we are also excited to announce the availability of RSS feeds of All-In-One Code Framework code samples. By using these feeds, you can easily track and download the new code samples. English RSS feeds All code samples: http://support.microsoft.com/rss/en/rss.xml ASP.NET code samples: http://support.microsoft.com/rss/en/ASPNET.xml Silverlight code samples: http://support.microsoft.com/rss/en/Silverlight.xml Azure code samples: http://support.microsoft.com/rss/en/Azure.xml COM code samples: http://support.microsoft.com/rss/en/COM.xml Data Platform code samples: http://support.microsoft.com/rss/en/Data%20Platform.xml Library code samples: http://support.microsoft.com/rss/en/Library.xml Office dev code samples: http://support.microsoft.com/rss/en/Office.xml VSX code samples: http://support.microsoft.com/rss/en/VSX.xml Windows 7 code samples: http://support.microsoft.com/rss/en/Windows%207.xml Windows Forms code samples: http://support.microsoft.com/rss/en/Windows%20Forms.xml Windows General code samples: http://support.microsoft.com/rss/en/Windows%20General.xml Windows Service code samples: http://support.microsoft.com/rss/en/Windows%20Service.xml Windows Shell code samples: http://support.microsoft.com/rss/en/Windows%20Shell.xml Windows UI code samples: http://support.microsoft.com/rss/en/Windows%20UI.xml WPF code samples: http://support.microsoft.com/rss/en/WPF.xml ??RSS?? ??????:http://support.microsoft.com/rss/zh-cn/codeplex/rss.xml ASP.NET????:http://support.microsoft.com/rss/zh-cn/codeplex/ASPNET.xml Silverlight????:http://support.microsoft.com/rss/zh-cn/codeplex/Silverlight.xml Azure ????: http://support.microsoft.com/rss/zh-cn/codeplex/Azure.xml COM ????: http://support.microsoft.com/rss/zh-cn/codeplex/COM.xml Data Platform ????: http://support.microsoft.com/rss/zh-cn/codeplex/Data%20Platform.xml Library ????: http://support.microsoft.com/rss/zh-cn/codeplex/Library.xml Office dev ????: http://support.microsoft.com/rss/zh-cn/codeplex/Office.xml VSX ????: http://support.microsoft.com/rss/zh-cn/codeplex/VSX.xml Windows 7 ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%207.xml Windows Forms ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%20Forms.xml Windows General ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%20General.xml Windows Service ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%20Service.xml Windows Shell ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%20Shell.xml Windows UI ????: http://support.microsoft.com/rss/zh-cn/codeplex/Windows%20UI.xml WPF ????: http://support.microsoft.com/rss/zh-cn/codeplex/WPF.xml

    Read the article

  • Load different levels in XML

    - by Anearion
    my question is more about a theoretical gener than a pratical way to make things happen. I'm about start developing a game for android, text based so i won't need sprites or animation, nor a game engine. Let's say is similar to a sudoku game, where each level is an harder version of sudoku and each level has some question to be asnwered over the sudoku itself. I was wondering if the better way is to have only one XML and then inside all the different levels, each one with his meta-tags, or if the different approach of making n xml files where each one is a level is preferred. At the moment a level should have those tags: <level> <question>Question_1</question> <hint1>what does it do?</hint1> <hint2>where...</hint2> .... <hintN>how...</hintN> </level> So each level could have some items to read and that's what made me think that maybe different files are better cuz if i have to load lvl 10 i can read only the 10.xml file. I hope my question isn't too stupind. Thanks in advance

    Read the article

  • XML Serialization and Soap Serialization

    - by Costa
    Hi I think even if we will not need interoperability between applications, and even we do not communicate with web services, it is easier to serialize using SoapFormatter than XmlSerializer because SOAP will serialize the private members by default, while XmlSerializer will work on public properties and fields. actually I cannot find a reason for using XmlSerializer, do I miss something? what is disadvantages of SoapFormatter. or what is advantage of XML serialization over Soap? (xsd) thanks

    Read the article

  • working python xml

    - by ricardo
    hello all, my question is the following, which is the best way of working XML (kml) with python?, especially script serializable. thanks for your attention and answers

    Read the article

  • Linq-to-XML query to select specific sub-element based on additional criteria

    - by BrianLy
    My current LINQ query and example XML are below. What I'd like to do is select the primary email address from the email-addresses element into the User.Email property. The type element under the email-address element is set to primary when this is true. There may be more than one element under the email-addresses but only one will be marked primary. What is the simplest approach to take here? Current Linq Query (User.Email is currently empty): var users = from response in xdoc.Descendants("response") where response.Element("id") != null select new User { Id = (string)response.Element("id"), Name = (string)response.Element("full-name"), Email = (string)response.Element("email-addresses"), JobTitle = (string)response.Element("job-title"), NetworkId = (string)response.Element("network-id"), Type = (string)response.Element("type") }; Example XML: <?xml version="1.0" encoding="UTF-8"?> <response> <response> <contact> <phone-numbers/> <im> <provider></provider> <username></username> </im> <email-addresses> <email-address> <type>primary</type> <address>[email protected]</address> </email-address> </email-addresses> </contact> <job-title>Account Manager</job-title> <type>user</type> <expertise nil="true"></expertise> <summary nil="true"></summary> <kids-names nil="true"></kids-names> <location nil="true"></location> <guid nil="true"></guid> <timezone>Eastern Time (US &amp; Canada)</timezone> <network-name>Domain</network-name> <full-name>Alice</full-name> <network-id>79629</network-id> <stats> <followers>2</followers> <updates>4</updates> <following>3</following> </stats> <mugshot-url> https://assets3.yammer.com/images/no_photo_small.gif</mugshot-url> <previous-companies/> <birth-date></birth-date> <name>alice</name> <web-url>https://www.yammer.com/domain.com/users/alice</web-url> <interests nil="true"></interests> <state>active</state> <external-urls/> <url>https://www.yammer.com/api/v1/users/1089943</url> <network-domains> <network-domain>domain.com</network-domain> </network-domains> <id>1089943</id> <schools/> <hire-date nil="true"></hire-date> <significant-other nil="true"></significant-other> </response> <response> <contact> <phone-numbers/> <im> <provider></provider> <username></username> </im> <email-addresses> <email-address> <type>primary</type> <address>[email protected]</address> </email-address> </email-addresses> </contact> <job-title>Office Manager</job-title> <type>user</type> <expertise nil="true"></expertise> <summary nil="true"></summary> <kids-names nil="true"></kids-names> <location nil="true"></location> <guid nil="true"></guid> <timezone>Eastern Time (US &amp; Canada)</timezone> <network-name>Domain</network-name> <full-name>Bill</full-name> <network-id>79629</network-id> <stats> <followers>3</followers> <updates>1</updates> <following>1</following> </stats> <mugshot-url> https://assets3.yammer.com/images/no_photo_small.gif</mugshot-url> <previous-companies/> <birth-date></birth-date> <name>bill</name> <web-url>https://www.yammer.com/domain.com/users/bill</web-url> <interests nil="true"></interests> <state>active</state> <external-urls/> <url>https://www.yammer.com/api/v1/users/1089920</url> <network-domains> <network-domain>domain.com</network-domain> </network-domains> <id>1089920</id> <schools/> <hire-date nil="true"></hire-date> <significant-other nil="true"></significant-other> </response> </response>

    Read the article

  • XML Schema (XSD) to Rails ActiveRecord Mapping?

    - by Incomethax
    I'm looking for a way to convert an XML Schema definition file into an ActiveRecord modeled database. Does anyone know of a tool that happens to do this? So far the best way I've found is to first load the XSD into an RDBMS like postgres or mysql and then have rails connect to do a rake db:schema:dump. This however, only leaves me with a database without rails Models. What would be the best way to import/load this xsd based database into rails?

    Read the article

  • How to add XML elements into the toolbox in Visual Studio 2010 RC

    - by Alex Marshall
    I'm trying to edit an XML schema in Visual Studio 2010 Ultimate RC, but when I go to the toolbox (with the schema open and focused) there's absolutely nothing in the Toolbox view, even when every tutorial out there that I've read tells me that there should be. I've tried using the context menu option for resetting the Toolbox to no effect. Is there something I'm missing ? Something I need to install to get this feature of Visual Studio going ?

    Read the article

  • c# linq to xml dynamic query

    - by David Archer
    Right, bit of a strange question; I have been doing some linq to XML work recently (see my other recent posts here and here). Basically, I want to be able to create a query that checks whether a textbox is null before it's value is included in the query, like so: XDocument db = XDocument.Load(xmlPath); var query = (from vals in db.Descendants("Customer") where (if(textbox1.Text != "") {vals.Element("CustomerID") == Convert.ToInt32(textbox1.Text) } || if(textbox2.Text != "") {vals.Element("Name") == textbox2.Text}) select vals).ToList();

    Read the article

  • How to generate following xml

    - by Mohsan
    hi. i want to generate XML for the following tree type structure. i attached picture. generated xml should be <services> <service> <name>Service 1</name> <categories> <category> <name>Cateogry 1</name> <methods> <method> <name>Method 1</name> </method> </methods> </category> </categories> </service> <service> <name>Service 2</name> <categories> <category> <name>Cateogry 1</name> <methods> <method> <name>Method 1</name> </method> </methods> </category> </categories> </service> <service> <name>Service 3</name> <categories> <category> <name>Cateogry 1</name> <methods> <method> <name>Method 1</name> </method> </methods> </category> </categories> </service> </services>

    Read the article

  • Specify XML schema data type of decimal or blank

    - by Jeremy Stein
    Is there a way in an XML schema to specify that an element may contain either an empty string or a decimal? If I specify the type as xs:decimal like this: <xs:element name="Sample" type="xs:decimal" /> then a blank value would not pass validation: <Sample/> (I realize that the best way to indicate no value would be to not include the element, but I was wondering if there was a way to allow blank or decimal.)

    Read the article

  • Digitally Sign Parts of a XML document

    - by Eros
    I have an XML document having structure similar to the following <envelop> <header>blaa</header> <message>blaa blaa</message> <footer></footer> </envelop> I want to digitally sign the header and message elements and add the signature to the footer element. How can I sign the elements and then later verify the signature (using .net c#) ?

    Read the article

  • Serialize a message format to xml

    - by anijhaw
    I have a python list as [ (A,{'a':1,'b':2,'c':3,'d':4}), B,{'a':1,'b':2,'c':3,'d':4}), ... ] I want to know if there is a standard library of serializing this kind of list to xml or should I hand code it to a file.

    Read the article

  • Dataset -> XML Document - Load DataSet into an XML Document - C#.Net

    - by NLV
    Hello I'm trying to read a dataset as xml and load it into an XML Document. XmlDocument contractHistoryXMLSchemaDoc = new XmlDocument(); using (MemoryStream ms = new MemoryStream()) { //XmlWriterSettings xmlWSettings = new XmlWriterSettings(); //xmlWSettings.ConformanceLevel = ConformanceLevel.Auto; using (XmlWriter xmlW = XmlWriter.Create(ms)) { xmlW.WriteStartDocument(); dsContract.WriteXmlSchema(xmlW); xmlW.WriteEndDocument(); xmlW.Close(); using (XmlReader xmlR = XmlReader.Create(ms)) { contractHistoryXMLSchemaDoc.Load(xmlR); } } } But I'm getting the error - "Root Element Missing". Any ideas? Update When i do xmlR.ReadInnerXML() it is empty. Does anyone know why? NLV

    Read the article

  • how to merge xml string to main xml document object

    - by CliffC
    how can i merge the following xml string <employee> <name>cliff</name> </employee> to my existing xml document object XmlDocument xmlDoc = new XmlDocument(); XmlElement xmlCompany = xmlDoc.CreateElement("Company"); the final output should look like <Company> <employee> <name>cliff</name> </employee> </Company> thanks

    Read the article

  • WCF Method is returning xml fragment but no xml UTF-8 header

    - by horls
    My method does not return the header, just the root element xml. internal Message CreateReturnMessage(string output, string contentType) { // create dictionaryReader for the Message byte[] resultBytes = Encoding.UTF8.GetBytes(output); XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader(resultBytes, 0, resultBytes.Length, Encoding.UTF8, XmlDictionaryReaderQuotas.Max, null); if (WebOperationContext.Current != null) WebOperationContext.Current.OutgoingResponse.ContentType = contentType; // create Message return Message.CreateMessage(MessageVersion.None, "", xdr); } However, the output I get is: <Test> <Message>Hello World!</Message> </Test> I would like the output to render as: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <Test> <Message>Hello World!</Message> </Test>

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >