Search Results

Search found 18472 results on 739 pages for 'vtd xml author'.

Page 27/739 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • Why does JAXB not create a member variable in its generated code when an XML schema base type and subtype have the same element declared in them?

    - by belltower
    I have a question regarding with regard to JAXB generated classes. As you can I see, I have a complex type, DG_PaymentIdentification1, declared in my schema. Its a restriction of PaymentIdentification1. DG_PaymentIdentification1 is also identical to PaymentIdentification1. I also have a type called DG_CreditTransferTransactionInformation10 which has a base type of CreditTransferTransactionInformation10 and is identical to it. I have included the relevant XML schema snippets below. <xs:complexType name="DG_PaymentIdentification1"> <xs:complexContent> <xs:restriction base="PaymentIdentification1"> <xs:sequence> <xs:element name="InstrId" type="DG_Max35Text_REF" minOccurs="0"/> <xs:element name="EndToEndId" type="DG_Max35Text_REF" id="DG-41"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="PaymentIdentification1"> <xs:sequence> <xs:element name="InstrId" type="Max35Text" minOccurs="0"/> <xs:element name="EndToEndId" type="Max35Text"/> </xs:sequence> </xs:complexType> <xs:complexType name="DG_CreditTransferTransactionInformation10"> <xs:complexContent> <xs:restriction base="CreditTransferTransactionInformation10"> <xs:sequence> <xs:element name="PmtId" type="DG_PaymentIdentification1"/> <xs:simpleType name="DG_Max35Text_REF"> <xs:restriction base="DG_NotEmpty35"> <xs:pattern value="[\-A-Za-z0-9\+/\?:\(\)\.,'&#x20;]*"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="Max35Text"> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:maxLength value="35"/> </xs:restriction> </xs:simpleType> JAXB generates the following java class for DG_PaymentIdentification1: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DG_CreditTransferTransactionInformDGion10") public class DGCreditTransferTransactionInformation10 extends CreditTransferTransactionInformation10 { } My question is why doesnt the DGCreditTransferTransactionInformation10 generated class have a variable of type DG_PaymentIdentification1 in the generated code? The base class CreditTransferTransactionInformation10 does have a type PaymentIdentification1 declared in it. Is there any way of ensuring that DGCreditTransferTransactionInformation10 will have a DG_PaymentIdentification1 in it?

    Read the article

  • Writing xml with powershell

    - by alex
    i have a script that get all the info i need about my SharePoint farm : [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} $webapps = @() foreach ($websvc in $websvcs) { write-output "Web Applications" write-output "" foreach ($webapp in $websvc.WebApplications) { write-output "Webapp Name -->"$webapp.Name write-output "" write-output "Site Collections" write-output "" foreach ($site in $webapp.Sites) { write-output "Site URL --> -->" $site.URL write-output "" write-output "Websites" write-output "" foreach ($web in $site.AllWebs) { write-output "Web URL --> --> -->" $web.URL write-output "" write-output "Lists" write-output "" foreach ($list in $web.Lists) { write-output "List Title --> --> --> -->" $list.Title write-output "" } foreach ($group in $web.Groups) { write-output "Group Name --> --> --> -->" $group.Name write-output "" foreach ($user in $group.Users) { write-output "User Name --> --> --> -->" $user.Name write-output "" } } } } } } i want to make the output to an XML file and then connect the xml file to HTML and make a site of it for manager use how can i do it ? thanks for the help !

    Read the article

  • Mac - KeyRemap4MacBook - Custom XML

    - by DjRikyx
    I hope someone of you know this powerfull Pref Panel to remap the keyboard.. Since i'm using a PC Keyboard, i wanted to make Screenshot a bit easy to do.. I managed to get working: -Command+Shift+3 to Stamp (full screen screenshot) -Command+Shift+4 to Control+Stamp (Selection Cursor Screenshot) Now i want to remap Shift+Stamp to Command+Shift+4+Space to get Windows Screenshot.. i tried but nothing was working.. Here is my current XML.. i only need to add the last remap! <?xml version="1.0"?> <root> <item> <name>Custom PC Style Screenshot</name> <appendix>Command+Shift_L+4+Space to Shift+F13</appendix> <appendix>Command+Shift_L+4 to Control+F13</appendix> <appendix>Command+Shift_L+3 to F13</appendix> <identifier>private.custom_pc_style_screenshot</identifier> <autogen></autogen> <autogen>--KeyToKey-- KeyCode::F13, VK_CONTROL, KeyCode::KEY_4, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L</autogen> <autogen>--KeyToKey-- KeyCode::F13, KeyCode::KEY_3, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L</autogen> Hope someone of you can help me out! Thank you

    Read the article

  • How could I embed formatted XML source in WORD documents?

    - by eckes
    I'm writing a documentation with WORD that contains XML source code (whole files) as examples. The way I'm embedding the currently XML is quite cumbersome and doesn't seem to me as really maintainable: I'm finishing the editing of the document in WORD and create a PDF from it using Acrobat next, I open my XML files (2x input files, 2x generated output files) with IE and print them with the PDF printer supplied by Acrobat now, I open up Acrobat Pro and attach the four XML-PDF files to my original document The problem with that work flow for me is that it involves too much manual labor in order to get the documentation done. What I've tried up to now is not really satisfying for me: converting each XML to PDF and appending them like described above opening the XML files with SCiTE, copy as RTF and paste into Word playing around with the LaTeX packages minted, pygments and listings (I could write the docs with LaTeX too) but found some unsolvable problems in each of these packages I'm searching for a way that produces my documentation more automatic. For example embedding the XML files including formatting of IE (which I find quite readable). The files should be included by reference so that I don't have to paste the XML sources manually every time the XML changes.

    Read the article

  • "Content is not allowed in prolog" when parsing perfectly valid XML on GAE

    - by Adrian Petrescu
    Hey guys, I've been beating my head against this absolutely infuriating bug for the last 48 hours, so I thought I'd finally throw in the towel and try asking here before I throw my laptop out the window. I'm trying to parse the response XML from a call I made to AWS SimpleDB. The response is coming back on the wire just fine; for example, it may look like: <?xml version="1.0" encoding="utf-8"?> <ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> <ListDomainsResult> <DomainName>Audio</DomainName> <DomainName>Course</DomainName> <DomainName>DocumentContents</DomainName> <DomainName>LectureSet</DomainName> <DomainName>MetaData</DomainName> <DomainName>Professors</DomainName> <DomainName>Tag</DomainName> </ListDomainsResult> <ResponseMetadata> <RequestId>42330b4a-e134-6aec-e62a-5869ac2b4575</RequestId> <BoxUsage>0.0000071759</BoxUsage> </ResponseMetadata> </ListDomainsResponse> I pass in this XML to a parser with XMLEventReader eventReader = xmlInputFactory.createXMLEventReader(response.getContent()); and call eventReader.nextEvent(); a bunch of times to get the data I want. Here's the bizarre part -- it works great inside the local server. The response comes in, I parse it, everyone's happy. The problem is that when I deploy the code to Google App Engine, the outgoing request still works, and the response XML seems 100% identical and correct to me, but the response fails to parse with the following exception: com.amazonaws.http.HttpClient handleResponse: Unable to unmarshall response (ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog.): <?xml version="1.0" encoding="utf-8"?> <ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"><ListDomainsResult><DomainName>Audio</DomainName><DomainName>Course</DomainName><DomainName>DocumentContents</DomainName><DomainName>LectureSet</DomainName><DomainName>MetaData</DomainName><DomainName>Professors</DomainName><DomainName>Tag</DomainName></ListDomainsResult><ResponseMetadata><RequestId>42330b4a-e134-6aec-e62a-5869ac2b4575</RequestId><BoxUsage>0.0000071759</BoxUsage></ResponseMetadata></ListDomainsResponse> javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source) at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(Unknown Source) at com.amazonaws.transform.StaxUnmarshallerContext.nextEvent(StaxUnmarshallerContext.java:153) ... (rest of lines omitted) I have double, triple, quadruple checked this XML for 'invisible characters' or non-UTF8 encoded characters, etc. I looked at it byte-by-byte in an array for byte-order-marks or something of that nature. Nothing; it passes every validation test I could throw at it. Even stranger, it happens if I use a Saxon-based parser as well -- but ONLY on GAE, it always works fine in my local environment. It makes it very hard to trace the code for problems when I can only run the debugger on an environment that works perfectly (I haven't found any good way to remotely debug on GAE). Nevertheless, using the primitive means I have, I've tried a million approaches including: XML with and without the prolog With and without newlines With and without the "encoding=" attribute in the prolog Both newline styles With and without the chunking information present in the HTTP stream And I've tried most of these in multiple combinations where it made sense they would interact -- nothing! I'm at my wit's end. Has anyone seen an issue like this before that can hopefully shed some light on it? Thanks!

    Read the article

  • utf8 problem with Perl and XML::Parser

    - by René Nyffenegger
    I encountered a problem dealing with utf8, XML and Perl. The following is the smallest piece of code and data in order to reproduce the problem. Here's an XML file that needs to be parsed: <?xml version="1.0" encoding="utf-8"?> <test> <words>???????????? ??????? ????????? ???? ???????????? ??????</words> <words>???????????? ??????? ????????? ???? ???????????? ??????</words> <words>???????????? ??????? ????????? ???? ???????????? ??????</words> [<words> .... </words> 148 times repeated] <words>???????????? ??????? ????????? ???? ???????????? ??????</words> <words>???????????? ??????? ????????? ???? ???????????? ??????</words> </test> The parsing is done with this perl script: use warnings; use strict; use XML::Parser; use Data::Dump; my $in_words = 0; my $xml_parser=new XML::Parser(Style=>'Stream'); $xml_parser->setHandlers ( Start => \&start_element, End => \&end_element, Char => \&character_data, Default => \&default); open OUT, '>out.txt'; binmode (OUT, ":utf8"); open XML, 'xml_test.xml' or die; $xml_parser->parse(*XML); close XML; close OUT; sub start_element { my($parseinst, $element, %attributes) = @_; if ($element eq 'words') { $in_words = 1; } else { $in_words = 0; } } sub end_element { my($parseinst, $element, %attributes) = @_; if ($element eq 'words') { $in_words = 0; } } sub default { # nothing to see here; } sub character_data { my($parseinst, $data) = @_; if ($in_words) { if ($in_words) { print OUT "$data\n"; } } } When the script is run, it produces the out.txt file. The problem is in this file on line 147. The 22th character (which in utf-8 consists of \xd6 \xb8) is split between the d6 and b8 with a new line. This should not happen. Now, I am interested if someone else has this problem or can reproduce it. And why I am getting this problem. I am running this script on Windows: C:\temp>perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread (with 5 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Binary build 1003 [285500] provided by ActiveState http://www.ActiveState.com Built May 13 2008 16:52:49

    Read the article

  • Parsing xml with php and xpath

    - by Hyung Suh
    Hey guys, I'm trying to parse an xml file to return a item with a specific id only, but having trouble making it work. here's what I have in php $xml_str = file_get_contents("test.xml"); $xml = simplexml_load_string($xml_str); $albid = $_GET['id']; $nodes = $xml->xpath('//library/book[@id=1]'); foreach($nodes as $node) { echo $node['title'].'<br/>'; } First, the php is not returning anything from the xml file. What would I need to fix to return the data? Also, how would I enter $albid into the xpath so that the id will be retrieved from the link? Any pointers in the right direction would be appreciated. Thanks! --and here's the sample xml file-- <library> <book id="1"> <title>PHP and MySQL</title> <author fname="miguel" lname="alvarez">Miguel Alvarez</author> </book> <book id="2"> <title>JAVA 123</title> <author fname="william" lname="vega">WIlliam Vega</author> </book>

    Read the article

  • Parsing google feed with linq to xml

    - by the_V
    Hi I'm trying to parse XML feed that I get via Google Contacts API with LINQ 2 XML. That's what feed looks like: <feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005"> <id>[email protected]</id> <updated>2010-06-11T17:37:06.561Z</updated> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" /> <title type="text">My Contacts</title> <link rel="alternate" type="text/html" href="http://www.google.com/" /> <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full" /> <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full" /> <link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full/batch" /> <link rel="self" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full?max-results=25" /> <author> <name>My NAme</name> <email>[email protected]</email> </author> <generator version="1.0" uri="http://www.google.com/m8/feeds">Contacts</generator> <openSearch:totalResults>19</openSearch:totalResults> <openSearch:startIndex>1</openSearch:startIndex> <openSearch:itemsPerPage>25</openSearch:itemsPerPage> <entry> <id>http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/base/0</id> <updated>2010-01-26T20:34:03.802Z</updated> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" /> <title type="text">Contact name</title> <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="http://www.google.com/m8/feeds/photos/media/myemailaddress%40gmail.com/0/O-ydnzWMJcfZWqT-6gGetw" /> <link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="http://www.google.com/m8/feeds/photos/media/myemailaddress%40gmail.com/0" /> <link rel="self" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full/0" /> <link rel="edit" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/myemailaddress%40gmail.com/full/0/1264538043802000" /> <gd:email rel="http://schemas.google.com/g/2005#other" address="[email protected]" primary="true" /> </entry> </feed> I've tried a number of things with linq 2 sql, but they didn't work. Even this simple code snipped doesn't work: using (FileStream stream = File.OpenRead("response.xml")) { XmlReader reader = XmlReader.Create(stream); XDocument doc = XDocument.Load(reader); XElement feed = doc.Element("feed"); if (feed == null) { Console.WriteLine("feed not found"); } XElement id = doc.Element("id"); if (id == null) { Console.WriteLine("id is null"); } } Problem is that both id and feed are null here. What wrong am I doing?

    Read the article

  • Blackberry XML Parsing Application not working

    - by Nirmal
    Hello All... I found one sample application from the Blackberry knowledgebase. From that application I have put that sample application on my eclipse plugin, and the code is as follows : import javax.microedition.io.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; import net.rim.device.api.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; class XML_Parsing_Sample extends UiApplication { // creating a member variable for the MainScreen MainScreen _screen = new MainScreen(); // string variables to store the values of the XML document String _node, _element; Connection _connectionthread; public static void main(String arg[]) { XML_Parsing_Sample application = new XML_Parsing_Sample(); // create a new instance of the application // and start the application on the event thread application.enterEventDispatcher(); } public XML_Parsing_Sample() { _screen.setTitle("XML Parsing");// setting title _screen.add(new RichTextField("Requesting.....")); _screen.add(new SeparatorField()); pushScreen(_screen); // creating a screen // creating a connection thread to run in the background _connectionthread = new Connection(); _connectionthread.start();// starting the thread operation } public void updateField(String node, String element) { // receiving the parsed node and its value from the thread // and updating it here // so it can be displayed on the screen String title = "My App"; _screen.add(new RichTextField(node + " : " + element)); if (node.equals(title)) { _screen.add(new SeparatorField()); } } private class Connection extends Thread { public Connection() { super(); } public void run() { // define variables later used for parsing Document doc; StreamConnection conn; try { // providing the location of the XML file, // your address might be different conn = (StreamConnection) Connector .open("http://www.sufalamtech.com/demo/moviewebservice/Test.xml"); // next few lines creates variables to open a // stream, parse it, collect XML data and // extract the data which is required. // In this case they are elements, // node and the values of an element DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docBuilderFactory .newDocumentBuilder(); docBuilder.isValidating(); doc = docBuilder.parse(conn.openInputStream()); doc.getDocumentElement().normalize(); NodeList list = doc.getElementsByTagName("*"); _node = new String(); _element = new String(); // this "for" loop is used to parse through the // XML document and extract all elements and their // value, so they can be displayed on the device for (int i = 0; i < list.getLength(); i++) { Node value = list.item(i).getChildNodes().item(0); _node = list.item(i).getNodeName(); _element = value.getNodeValue(); updateField(_node, _element); }// end for }// end try // will catch any exception thrown by the XML parser catch (Exception e) { Dialog.alert("exception = " + e); } }// end connection function }// end connection class }// end XML_Parsing_Sample But when I am running this application, the simulator just showing me a Blank screen with label Requesting... Anybody help me out for this ? Thanks in advance...

    Read the article

  • How can I Add newer Data to the start of the xml file (Example inside)

    - by Ofear
    Hi All! After alot of work i finish to make a xml reader and writer... but my problem is that i want the newer data that i insert using my form will be added to the top of the xml file. and not in the bottom.. let me show you an example: this is the XML file: <?xml version="1.0" encoding="utf-8"?> <events> <record> <event>old event</event> <eventDate>1/1/2009</eventDate> <desc>old desc</desc> </record> <record> <event>newer event</event> <eventDate>12/12/2011</eventDate> <desc>newer desc</desc> </record> </events> now.. I want the XML file to be like this: newer data and then old data <?xml version="1.0" encoding="utf-8"?> <events> <record> <event>newer event</event> <eventDate>12/12/2011</eventDate> <desc>newer desc</desc> </record> <record> <event>old event</event> <eventDate>1/1/2009</eventDate> <desc>old desc</desc> </record> </events> This is my add.php (the file that get the POST information from the Form in the main.html : <?php $record = array( 'event' => $_POST['event'], 'eventDate' => $_POST['eventDate'], 'desc' => $_POST['desc'], ); $doc = new DOMDocument(); $doc->load( 'events.xml' ); $doc->formatOutput = true; $r = $doc->getElementsByTagName("events")->item(0); $b = $doc->createElement("record"); $event = $doc->createElement("event"); $event->appendChild( $doc->createTextNode( $record["event"] ) ); $b->appendChild( $event ); $eventDate = $doc->createElement("eventDate"); $eventDate->appendChild( $doc->createTextNode( $record["eventDate"] ) ); $b->appendChild( $eventDate ); $desc = $doc->createElement("desc"); $desc->appendChild( $doc->createTextNode( $record["desc"] ) ); $b->appendChild( $desc ); $r->appendChild( $b ); $doc->save("events.xml"); header("Location: {$_SERVER['HTTP_REFERER']}"); ?> Where do i need to edit to be able to make the *xml as i want?*

    Read the article

  • Importing an XML file into excel

    - by Sudhee
    I have a multilevel XML file. When I import the XML into excel, it creates multiple columns for the multilevel data. However, I need the multilevel data as additional rows. Is there any way I can achieve this ? Thanks a lot for your help. My XML File: <L1> <L1dataId>07320</L1dataId> <DateDetail>13-Oct-2013</DateDetail> <TypeDetail> <TypeId>1</TypeId> <Rate1> <Current> <onsite>100</onsite> <net>100</net> <gross>100</gross> </Current> <Past> <onsite>100</onsite> <net>100</net> <gross>100</gross> </Past> </Rate1> <Rate2> <Current> <onsite>2100</onsite> <net>2100</net> <gross>2100</gross> </Current> <Past> <onsite>2100</onsite> <net>2200</net> <gross>1200</gross> </Past> </Rate2> <Rate3> <Current> <onsite>300</onsite> <net>300</net> <gross>300</gross> </Current> <Past> <onsite>400</onsite> <net>400</net> <gross>400</gross> </Past> </Rate3> </TypeDetail> <TypeDetail> <TypeId>2</TypeId> <Rate1> <Current> <onsite>100</onsite> <net>100</net> <gross>100</gross> </Current> <Past> <onsite>100</onsite> <net>100</net> <gross>100</gross> </Past> </Rate1> <Rate2> <Current> <onsite>2100</onsite> <net>2100</net> <gross>2100</gross> </Current> <Past> <onsite>2100</onsite> <net>2200</net> <gross>1200</gross> </Past> </Rate2> <Rate3> <Current> <onsite>300</onsite> <net>300</net> <gross>300</gross> </Current> <Past> <onsite>400</onsite> <net>400</net> <gross>400</gross> </Past> </Rate3> </TypeDetail> </L1> How Excel converts it and how I need it:

    Read the article

  • Removing the XML Formatter from ASP.NET Web API Applications

    - by Rick Strahl
    ASP.NET Web API's default output format is supposed to be JSON, but when I access my Web APIs using the browser address bar I'm always seeing an XML result instead. When working on AJAX application I like to test many of my AJAX APIs with the browser while working on them. While I can't debug all requests this way, GET requests are easy to test in the browser especially if you have JSON viewing options set up in your various browsers. If I preview a Web API request in most browsers I get an XML response like this: Why is that? Web API checks the HTTP Accept headers of a request to determine what type of output it should return by looking for content typed that it has formatters registered for. This automatic negotiation is one of the great features of Web API because it makes it easy and transparent to request different kinds of output from the server. In the case of browsers it turns out that most send Accept headers that look like this (Chrome in this case): Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Web API inspects the entire list of headers from left to right (plus the quality/priority flag q=) and tries to find a media type that matches its list of supported media types in the list of formatters registered. In this case it matches application/xml to the Xml formatter and so that's what gets returned and displayed. To verify that Web API indeed defaults to JSON output by default you can open the request in Fiddler and pop it into the Request Composer, remove the application/xml header and see that the output returned comes back in JSON instead. An accept header like this: Accept: text/html,application/xhtml+xml,*/*;q=0.9 or leaving the Accept header out altogether should give you a JSON response. Interestingly enough Internet Explorer 9 also displays JSON because it doesn't include an application/xml Accept header: Accept: text/html, application/xhtml+xml, */* which for once actually seems more sensible. Removing the XML Formatter We can't easily change the browser Accept headers (actually you can by delving into the config but it's a bit of a hassle), so can we change the behavior on the server? When working on AJAX applications I tend to not be interested in XML results and I always want to see JSON results at least during development. Web API uses a collection of formatters and you can go through this list and remove the ones you don't want to use - in this case the XmlMediaTypeFormatter. To do this you can work with the HttpConfiguration object and the static GlobalConfiguration object used to configure it: protected void Application_Start(object sender, EventArgs e) { // Action based routing (used for RPC calls) RouteTable.Routes.MapHttpRoute( name: "StockApi", routeTemplate: "stocks/{action}/{symbol}", defaults: new { symbol = RouteParameter.Optional, controller = "StockApi" } ); // WebApi Configuration to hook up formatters and message handlers RegisterApis(GlobalConfiguration.Configuration); } public static void RegisterApis(HttpConfiguration config) { // remove default Xml handler var matches = config.Formatters .Where(f = f.SupportedMediaTypes .Where(m = m.MediaType.ToString() == "application/xml" || m.MediaType.ToString() == "text/xml") .Count() 0) .ToList() ; foreach (var match in matches) config.Formatters.Remove(match); } } That LINQ code is quite a mouthful of nested collections, but it does the trick to remove the formatter based on the content type. You can also look for the specific formatter (XmlMediatTypeFormatter) by its type name which is simpler, but it's better to search for the supported types as this will work even if there are other custom formatters added. Once removed, now the browser request results in a JSON response: It's a simple solution to a small debugging task that's made my life easier. Maybe you find it useful too…© Rick Strahl, West Wind Technologies, 2005-2012Posted in Web Api  ASP.NET   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • Don’t string together XML

    - by KyleBurns
    XML has been a pervasive tool in software development for over a decade.  It provides a way to communicate data in a manner that is simple to understand and free of platform dependencies.  Also pervasive in software development is what I consider to be the anti-pattern of using string manipulation to create XML.  This usually starts with a “quick and dirty” approach because you need an XML document and looks like (for all of the examples here, we’ll assume we’re writing the body of a method intended to take a Contact object and return an XML string): return string.Format("<Contact><BusinessName>{0}</BusinessName></Contact>", contact.BusinessName);   In the code example, I created (or at least believe I created) an XML document representing a simple contact object in one line of code with very little overhead.  Work’s done, right?  No it’s not.  You see, what I didn’t realize was that this code would be used in the real world instead of my fantasy world where I own all the data and can prevent any of it containing problematic values.  If I use this code to create a contact record for the business “Sanford & Son”, any XML parser will be incapable of processing the data because the ampersand is special in XML and should have been encoded as &amp;. Following the pattern that I have seen many times over, my next step as a developer is going to be to do what any developer in his right mind would do – instruct the user that ampersands are “bad” and they cannot be used without breaking computers.  This may work in many cases and is often accompanied by logic at the UI layer of applications to block these “bad” characters, but sooner or later someone is going to figure out that other applications allow for them and will want the same.  This often leads to the creation of “cleaner” functions that perform a replace on the strings for every special character that the person writing the function can think of.  The cleaner function will usually grow over time as support requests reveal characters that were missed in the initial cut.  Sooner or later you end up writing your own somewhat functional XML engine. I have never been told by anyone paying me to write code that they would like to buy a somewhat functional XML engine.  My employer/customer’s needs have always been for something that may use XML, but ultimately is functionality that drives business value. I’m not going to build an XML engine. So how can I generate XML that is always well-formed without writing my own engine?  Easy – use one of the ones provided to you for free!  If you’re in a shop that still supports VB6 applications, you can use the DomDocument or MXXMLWriter object (of the two I prefer MXXMLWriter, but I’m not going to fully describe either here).  For .Net Framework applications prior to the 3.5 framework, the code is a little more verbose than I would like, but easy once you understand what pieces are required:             using (StringWriter sw = new StringWriter())             {                 using (XmlTextWriter writer = new XmlTextWriter(sw))                 {                     writer.WriteStartDocument();                     writer.WriteStartElement("Contact");                     writer.WriteElementString("BusinessName", contact.BusinessName);                     writer.WriteEndElement(); // end Contact element                     writer.WriteEndDocument();                     writer.Flush();                     return sw.ToString();                 }             }   Looking at that code, it’s easy to understand why people are drawn to the initial one-liner.  Lucky for us, the 3.5 .Net Framework added the System.Xml.Linq.XElement object.  This object takes away a lot of the complexity present in the XmlTextWriter approach and allows us to generate the document as follows: return new XElement("Contact", new XElement("BusinessName", contact.BusinessName)).ToString();   While it is very common for people to use string manipulation to create XML, I’ve discussed here reasons not to use this method and introduced powerful APIs that are built into the .Net Framework as an alternative.  I’ve given a very simplistic example here to highlight the most basic XML generation task.  For more information on the XmlTextWriter and XElement APIs, check out the MSDN library.

    Read the article

  • jqGrid adding new row with XML Data

    - by mahr.g.mohyuddin
    Hi Everyone, I am using jQGrid in my ASP.NET MVC application with add row feature. My problem is I have to save XML data in some of the row fields. But while posting the new row with some fields having plain xml, to server I get Internal server error. By default jqGrid perhaps expects json or text data to be posted on server while adding a new row. I used beforeSubmit method for workaround to convert xml first to json and then send to server, but while converting json back to xml I lose the orginal structure of the xml. FYI: I used JsonReaderWriterFactory on server to convert it back. Your help will be highly appreciated. Thanks.

    Read the article

  • use jsonp to get xml cross domain

    - by lmkk
    I am trying to read xml into a webpage from another server, and I assume that my problem is Same-Origin Policy, and therefore a cross domain problem. I have a bit of googling and it seems that jsonp is the way forward. Based on some examples I found here on stackoverflow and another sites, this is what I have, and it does not "hit" the server with the xml. I can view the xml in a browser. $(document).ready(function(){ $.ajax({ type: 'GET', dataType: 'jsonp', url: 'http://192.168.0.106:8111/getconfiguration?', success: function (xml) { //do stuff with received xml }}); Any suggestions? please keep in mind that I am a newbie with regards to JS / JQuery ;o)

    Read the article

  • Can I separate portions of my plugin.xml file into multiple xml files for an Eclipse plugin?

    - by wildabeast
    I have created an eclipse plugin, with a plugin.xml file. I have created an extension to the org.eclipse.wst.common.snippets.SnippetContributions extension point. The xml contents of this extension point has gotten really big. Is there a way that I can move the contents of my snippets extension to a separate file? Something like this: In plugin.xml: <extension point="org.eclipse.wst.common.snippets.SnippetContributions" file="snippets.xml"></extenstion> and in snippets.xml: <category ....> <item..../item> </category>...

    Read the article

  • Building an XML editor in java and RichFaces

    - by Mark Lewis
    Hello I'm building an XML editor using the above technologies. In essence, I want to read in a whole XML file to a java object, and refer using this object to each element in the XML node tree (grouped into entries) to display the content locked, have separate padlocks for the user to click to 'unlock' an entry allow overwriting of the data, and to submit this entry. 'Add entry', 'Duplicate entry', 'Delete entry' are also functions I'd like to add. I already use dom4j and XPath to access areas of the XML file so some of the work in theory is already done. Given the above, I was going to use these two together with inplaceInputs to allow the user to edit the XML and JSF validators to check the data coming in. Is this the best way to approach this problem, or is there a more straightforward route than XPathing a whole record? I started looking at jaxb but I'm new at java and jsf but I've got the feeling I won't be by the end.. Thanks

    Read the article

  • XML Document Depth?

    - by CrazyNick
    How to find the depth of the xml file using powershell/xpath? consider the below xml: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title>Harry Potter</title> <price>25.99</price> </book> <book> <title>Learning XML</title> <price>49.95</price> </book> </bookstore> depth of the above xml document is 3 (bookstore - book - title/price).

    Read the article

  • XML sitemap 404 page and .htaccess issue (phpvibe)

    - by Lachit
    I figure out a xml sitemap for my website. In .htaccess, if I comment (RewriteRule ^(.*)/?$ index.php?rp=$1 [L]) line then all xml sitemap works fine, but my website pages doesn't work. Please check this links.... www.streaminghub.org/test/sitemap.php -- Working www.streaminghub.org/test/sitemap_1.xml --- working www.streaminghub.org/test/video/5439/samsung-nf110-english-hands-on-at-ifa-2010/ --- Not working My .htaccess file.... <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /test/ RewriteRule ^embed/([^/]*)/$ /embed.php?id=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d **RewriteRule ^(.*)/?$ index.php?rp=$1 [L]** **RewriteRule ^sitemaps.xml sitemap.php** **RewriteRule ^sitemap_(.*).xml?$ sitemap.php?page=$1 [L]** </IfModule> I think it's a .htaccess issue, I am using phpvibe script. I don't have knowledge with .htaccess, kindly help me to figure this issue. Thank you.

    Read the article

  • C# Stream Reader adding \n to XML

    - by Terry
    I use the StreamReader class to obtain XML for my GeoCoding process from Google. StreamReader srGeoCode = new StreamReader(WebRequest.Create(Url).GetResponse().GetResponseStream()); String GeoCodeXml = srGeoCode.ReadToEnd(); XmlDocument XmlDoc = new XmlDocument(); GeoCode oGeoCode = new GeoCode(); XmlDoc.Load(GeoCodeXml); I get XML back but it adds \n and other extras to the XML <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<kml xmlns=\"http://earth.google.com/kml/2.0\"><Response>\n <name> I have the same code in VB and it does not do this. I can successfully GeoCode my information using the VB version of this console app. Is there a reason the C# version adds this extra data to the XML that I retrieve back? I am trying my best to convert everything over to C#. I enjoy coding in it over VB.

    Read the article

  • digital signature - detached Pkcs#7 to XML-DSIG

    - by Alois
    Hi! I am struggling with the following scenario: an XML-message is created client-side and digitally signed using mozilla's window.crypto.signText. After signing, the message and the signature are transmitted via a webservice (.net) to the server. Everything is fine until this point. on the server, the XML shall be included in another XML-document, which is publicly accessible. The signature should be published as well in order to grant non-repudiation. Q: Is there a smooth option to convert the detached Pkcs#7 into XML-DSIG (e.g. functionality within the .net framework)? Q2: Or is it possible to create the XML-DSIG already client-side without using external plugins? Tnx for your help! Alois Paulin

    Read the article

  • Rails XML Builder - Code refactoring

    - by Vijay Dev
    I have written the following code in my Rails app to generate XML. I am using Aptana IDE to do Rails development and the IDE shows a warning that the code structure is identical in both the blocks. What changes can be done to the code to remove the duplicity in structure? Is there any other way to write the same? xml.roles do @rolesList.each do |r| xml.role(:id => r["role_id"], :name => r["role_name"]) end end xml.levels do @levelsList.each do |lvl| xml.level(:id => lvl["level_id"], :name => lvl["level_name"]) end end

    Read the article

  • InvalidOperationException When XML Serializing Inherited Class

    - by Nick
    I am having an issue serializing a c# class to an XML file that has a base class... here is a simple example: namespace Domain { [Serializable] public class ClassA { public virtual int MyProperty { get; set; } } } namespace Derived { public class ClassA : Domain.ClassA { public override int MyProperty { get { return 1; } set { /* Do Nothing */ } } } } When I attempt to serialize an instance of Derived.ClassA, I receive the following exception: InvalidOperationException(Types 'Domain.ClassA' and 'Derived.ClassA' both use the XML type name 'ClassA', from the namespace ". Use XML attributes to specify a unique XML name and/or namespace for the type.) The problem is that I want to create a single base class that simply defines the structure of the XML file, and then allow anyone else to derive from that class to insert business rules, but that the formatting will come through from the base. Is this possible, and if so, how do I attribute the base class to allow this?

    Read the article

  • Injecting an XML fragment into the current document from an external file

    - by makenai
    I'm currently parsing an XML file using REXML and trying to come up with a way of inserting an XML fragment from an internal file. Currently, I'm using some logic like the following: doc.elements.each('//include') do |element| handleInclude( element ) end def handleInclude( element ) if filename = element.attributes['file'] data = File.open( filename ).read doc = REXML::Document.new( data ) element.parent.replace_child( element, doc ) end end Where my XML looks like the following: <include file="test.xml" /> But this seems a little bit clunky, and I'm worried that REXML might not always parse XML fragments correctly due to absence of a proper root node in some cases. Is there a better way of doing this? Concern #2: REXML seems not to pick up my changes after I replace elements. For example, after making a change: doc.elements.each('rootNode/*') do |element| end ..picks up neither the original element I replaced, nor the one I replaced it with. Is there some trick to getting REXML to rescan its' tree?

    Read the article

  • Use a folder of xml files as data source for nhibernate

    - by Bart Van Eyndhoven
    I'm going to start writing NUnit tests for a few classes in my project. A certain number of these classes use data gathered through nhibernate from a sql server 2008 database. The part of the program I'm about to test is very specific (and complicated). Therefore I have made a folder of xml files. Combined, the xml files could result in the database structure. I mean each xml file corresponds to a table in the database. The data in the xml files is also consistent with the database. Is there a way to use this folder of xml files as data source for nhibernate? I mean: can I use nhibernate to gather my test data (wich I have specifically chosen) instead of data from the database? In this way, I could usefully test this component without corrrupting the (test) database for future tests.

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >