Search Results

Search found 58802 results on 2353 pages for 'system xml'.

Page 49/2353 | < Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >

  • Converting Python Script to Vb.NET - Involves Post and Input XML String

    - by Jason Shoulders
    I'm trying to convert a Python Script to Vb.Net. The Python Script appears to accept some XML input data and then takes it to a web URL and does a "POST". I tried some VB.NET code to do it, but I think my approach is off because I got an error back "BadXmlDataErr" plus I can't really format my input XML very well - I'm only doing string and value. The input XML is richer than that. Here is an example of what the XML input data looks like in the Python script: <obj is="MyOrg:realCommand_v1/" > <int name="priority" val="1" /> <real name="value" val="9.5" /> <str name="user" val="MyUserName" /> <reltime name="overrideTime" val="PT60S"/> </obj> Here's the Vb.net code I attempted to convert that: Dim reqparm As New Specialized.NameValueCollection reqparm.Add("priority", "1") reqparm.Add("value", "9.5") reqparm.Add("user", "MyUserName") reqparm.Add("overrideTime", "PT60S") Using client As New Net.WebClient Dim sTheUrl As String = "[My URL]" Dim responsebytes = client.UploadValues(sTheUrl, "POST", MyReqparm) Dim responsebody = (New System.Text.UTF8Encoding).GetString(responsebytes) End Using I feel like I should be doing something else. Can anyone point me to the right direction?

    Read the article

  • Parsing XML in Javascript getElementsByTagName not working

    - by Probocop
    Hi, I am trying to parse the following XML with javascript: <?xml version='1.0' encoding='UTF-8'?> <ResultSet> <Result> <URL>www.asd.com</URL> <Value>10500</Value> </Result> </ResultSet> The XML is generated by a PHP script to get how many pages are indexed in Bing. My javascript function is as follows: function bingIndexedPages() { ws_url = "http://archreport.epiphanydev2.co.uk/worker.php?query=bingindexed&domain="+$('#hidden_the_domain').val(); $.ajax({ type: "GET", url: ws_url, dataType: "xml", success: function(xmlIn){ alert('success'); result = xmlIn.getElementsByTagName("Result"); $('#tb_actualvsindexedbing_indexed').val($(result.getElementsByTagName("Value")).text()); $('#img_actualvsindexedbing_worked').attr("src","/images/worked.jpg"); }, error: function() {$('#img_actualvsindexedbing_worked').attr("src","/images/failed.jpg");} }); } The problem I'm having is firebug is saying: 'result.getElementsByTagName is not a function' Can you see what is going wrong? Thanks

    Read the article

  • How to compare dictonary key with xml attribute value in xml using LINQ in c #?

    - by Pramodh
    Dear all, i've a dictonary " dictSample " which contains 1 data1 2 data2 3 data3 4 data4 and an xml file"sample.xml" in the form of: <node> <element id="1" value="val1"/> <element id="2" value="val2"/> <element id="3" value="val3"/> <element id="4" value="val4"/> <element id="5" value="val5"/> <element id="6" value="val6"/> <element id="7" value="val7"/> </node> i need to match the dictonary keys with the xml attribute id and to insert the matching id and the value of attribute"value" into another dictonary now i'm using like: XmlDocument XDOC = new XmlDocument(); XDOC.Load("Sample.xml"); XmlNodeList NodeList = XDOC.SelectNodes("//element"); Dictionary<string, string> dictTwo = new Dictionary<string, string>(); foreach (string l_strIndex in dictSample .Keys) { foreach (XmlNode XNode in NodeList) { XmlElement XEle = (XmlElement)XNode; if (dictSample[l_strIndex] == XEle.GetAttribute("id")) dictTwo.Add(dictSample[l_strIndex], XEle.GetAttribute("value").ToString()); } } please help me to do this in a simple way using LINQ

    Read the article

  • Using FOR XML AUTO against a synonym

    - by Rick
    We've just switched to synonyms for linked server stuff, and noticed that our FOR XML output is no longer correct. When returning XML results from a view, we could alias the view and that would be assigned as the element name. With synonyms, however, it seems to ignore the alias? We're still mostly on SQL 2005 - this bug doesn't seem to happen on our 2008 instance. Is this a known problem, and any ideas for work-arounds? For example, this is what we used to be able to do: select top 3 number from Numbers as elementname for xml auto <elementname number="0"/><elementname number="1"/><elementname number="2"/> And this is what happens with a synonym: select top 3 number from Numbers_synonym as elementname for xml auto <dbo.Numbers number="0"/><dbo.Numbers number="1"/><dbo.Numbers number="2"/> As you can see, SQL Server seems to use the name of the actual referenced object instead of the alias. This gets worse for cross server queries, because you get the four-part name instead of the nice alias. (eg: <rick_server.rick_database.dbo.Numbers number="0"/>...)

    Read the article

  • read xml in javascript problem

    - by Najmi
    hai all, i have a problem with my code to read the xml.I have use ajax to read xml data and populate it in combobox. My problem is it only read the first data.Here is my code my xml like this <area> <code>1</code> <name>area1</name> </area> <area> <code>2</code> <name>area2</name> </area> and my javascript if(http.readyState == 4 && http.status == 200) { //get select elements var item = document.ProblemMaintenanceForm.elements["probArea"]; //empty combobox item.options.length = 0; //read xml data from action file var test = http.responseXML.getElementsByTagName("area"); alert(test.length); for ( var i=0; i < test.length; i++ ){ var tests = test[i]; item.options[item.options.length] = new Option(tests.getElementsByTagName("name")[i].childNodes[i].nodeValue,tests.getElementsByTagName("code")[i].childNodes[i].nodeValue); } }

    Read the article

  • rails xml to active record object

    - by Brian D.
    I've been googling for a while to try and convert and incoming XML request into an active record object. I've tried using the ActiveRecordObject.new.from_xml method but it doesn't seem to handle relationships. For example, say I have the following xml: <blog> <title></title> <blog-pages> <blog-page> <page-number></page-number> <content></content> </blog-page> </blog-pages> </blog> And I have the following model objects: class Blog < ActiveRecord::Base has_many :blog_pages end class BlogPage < ActiveRecord::Base belongs_to :blog end Is there a way to convert the xml into a blog object WITH relationships? Or do I need to manually parse the XML? Thanks in advance.

    Read the article

  • How to append new elements to Xml from stream

    - by Wololo
    I have a method which returns some xml in a memory stream private MemoryStream GetXml() { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (MemoryStream memoryStream = new MemoryStream()) { using (XmlWriter writer = XmlWriter.Create(memoryStream, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("root"); writer.WriteStartElement("element"); writer.WriteString("content"); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } return memoryStream; } } In this example the format of the xml will be: <?xml version="1.0" encoding="utf-8"?> <root> <element>content</element> </root> How can i insert a new element under the root e.g <?xml version="1.0" encoding="utf-8"?> <root> <element>content</element> ----->New element here <------ </root>

    Read the article

  • Sorting XML file through multiple attributes

    - by jbugeja
    I want to sort a 'free-form' XML file through multiple attributes (first by T and then by L). The XML is a bit complex and it is structured as shown below: <?xml version="1.0" encoding="utf-8"?> <wb xmlns:cf="http://www.macromedia.com/2004/cfform" xmlns:a="urn:dummy"> <a:form name="chart"> <a:fieldset FIELD="a" FIELDNAME="FieldSet1"> <a:select1 FIELDNUMBER="01" L="1" T="2" /> <a:input FIELDNUMBER="02" INDEX="4" L="200" T="1" /> </a:fieldset> <a:fieldset FIELD="b" FIELDNAME="FieldSet1"> <a:select1 FIELDNUMBER="03" T="3" L="1" /> <a:input FIELDNUMBER="04" INDEX="7" T="4" L="200" /> <a:fieldset FIELD="c" FIELDNAME="FieldSet1"> <a:input FIELDNUMBER="05" T="10" INDEX="6" L="400" /> <a:input FIELDNUMBER="06" T="8" INDEX="8" L="200" /> </a:fieldset> </a:fieldset> <a:input FIELDNUMBER="08" INDEX="3" L="3" T="5" /> <a:input FIELDNUMBER="09" INDEX="2" L="2" T="4" /> </a:form> </wb> PS: The root element is wb and this is always followed by a:form The L and T are always found in elements that have a tag in the namespace a, the only exception being a:fieldset which does not have L and T a:fieldset could have multiple children of the namespace a including another a:fieldset We can also assume that L denotes Left and T denotes Top. So, the idea of this is that when I view the transformed XML I can immediately note which elements precede what. What's your take on this?

    Read the article

  • XML File as Excel file.

    - by FrustratedWithFormsDesigner
    I have a number of reports that I run against my database that need to eventually go to the end-users as Excel spreadsheets. Initially, I was creating text reports, but the steps to convert the text to a spreadsheet were a bit cumbersome. There were too many steps to import text to the spreadsheet, and multi-line text rows were imported as individual rows in Excel (which was incorrect). Currently, I am generating simple XML saving the file with an ".xls" extension. This works better, but there is still the problem of Excel prompting the user with an XML import dialogue every time they open the file, and then having to save a new file if they add notes or change the layout to the file (which they almost certainly will be doing). Sample "xls" file: <?xml version="1.0" standalone="yes"?> <report_rows> <row> <NAME>Test Data</NAME> <COUNT>345</COUNT> </row> <!-- many more row elements... --> </report_rows> Is there any way to add markup to the file to hint to Excel how it should import and handle the file? Ideally, the end user should be able to open and save the file like any othe spreadsheet they create directly from Excel. Is this even possible? UPDATE: We are running Office 2003 here. UPDATE: The XML is generated from a sqlplus script, no option to use C#/.NET here.

    Read the article

  • Sending XML to Servlet from Action Script

    - by John Doe
    I am only getting empty arrays on output. Anyone know what Exactly I'm doing wrong? package myDungeonAccessor; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class myDungeonAccessorServlet extends HttpServlet { private myDungeonAccessor dataAccessor; /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* TODO output your page here out.println("<html>"); out.println("<head>"); out.println("<title>Servlet myDungeonAccessorServlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Servlet myDungeonAccessorServlet at " + request.getContextPath () + "</h1>"); out.println("</body>"); out.println("</html>"); */ } finally { out.close(); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); // PrintWriter out = response.getWriter(); System.out.println("yo mom"); } /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //System.out.println("heppo"); //dataAccessor = new myDungeonAccessor(); System.out.println("Hello"); try { System.out.println("HEADERS: " + request.getHeaderNames()); ObjectInputStream in = new ObjectInputStream(request.getInputStream()); ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream()); } catch(Exception e) { e.printStackTrace(); } System.out.println("WAZZUP"); byte [] buffer = new byte[4096]; //in.read(buffer); System.out.println("TEST!"); String s = new String(buffer); System.out.println("Update S:" + s); } /** * Returns a short description of the servlet. * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; } }

    Read the article

  • JavaScript, jQuery, XML - if statement not executing for unknown reason

    - by Jack Roscoe
    Hi, I have a 'for' loop which extracts data from an XML document and adds it into some JavaScript objects, each time the loop executes I want it to run a certain function depending on the value of the attribute 'typ' which is being retrieved from the xml. Currently, the data from the XML is successfully being parsed, which is proven by the first 'alert' you can see which produces the correct value. However, neither of the 'alert' lines in the 'if' statement lower down are being executed and as a result I cannot test the 'ctyp3' function which is supposed to be called. Where have I gone wrong? for (j=0; j<arrayIds.length; j++) { $(xml).find("C[ID='" + arrayIds[j] + "']").each(function(){ // pass values questions[j] = { typ: $(this).attr('typ'), width: $(this).find("I").attr('wid'), height: $(this).find("I").attr('hei'), x: $(this).find("I").attr('x'), y: $(this).find("I").attr('x'), baC: $(this).find("I").attr('baC'), boC: $(this).find("I").attr('boC'), boW: $(this).find("I").attr('boW') } alert($(this).attr('typ')); if ($(this).attr('typ') == '3') { ctyp3(x,y,width,height,baC); alert('pass'); } else { // Add here alert('fail'); } }); }

    Read the article

  • XML parsing problem

    - by Albinoswordfish
    I'm having this strange XML parsing problem. I have this XML string I'm trying to parse <?xml version="1.0"?> <response status="success"> <lot>32342</lot> </response> I'm using XPath with Java in order to do this. I'm using the Xpath expression "/response/@status" to find the text "success". However whenever I evaluate this expression I get an empty string. However I am able to successfully parse this string using "/response/@type" <?xml version="1.0"?> <response type="success"> <lot>32342</lot> </response> So why would simply changing the name of the attribute change the return string to nothing? is = new InputSource(testWOcreateStrGood); xPathexpressionSuccess = xPath.compile("/response/@status"); responseStr = xPathexpressionSuccess.evaluate(is); reponseStr is the string I posted earlier with the "status" attribute

    Read the article

  • Navigating sorted XML data (XSLT)

    - by Andrew Parisi
    I have an XML file with company data in it, for 30 companies across 8 industries, on a portfolio page. The user has the option to sort this data by Industry, and this XML file will be added to constantly. This sorting is done in my XSL file using <xsl:choose>. Example: <xsl:when test="(invest[@investid='con'])"> <xsl:for-each select="$invest-port/portfolio/company[@industry='Communications']"> <xsl:sort select="name" /> <div class="invest-port-thumb"> <a> <xsl:attribute name="href"> <xsl:value-of select="link" /> </xsl:attribute> </a> </div> </xsl:for-each> </xsl:when> When navigating to an individual company's page, there are "previous" and "next" buttons at the bottom of the window. My issue is that I need these to dynamically link to the previous and next elements from within the XML data that has been sorted. Is this possible? Or is there an easier way to do this? (such as place each company in industry-divided XML files instead of one) Any insight would be greatly appreciated!

    Read the article

  • Problem with LINQ to XML and Namespaces

    - by abtcabe
    I am having problems with working with a third party XML string that contains a Namespace with LINQ to XML. In the below code everything works find. I am able to select the xElement (xEl1) and update its value. 'Example Without Namespace Dim XmlWithOutNs = _ <?xml version="1.0"?> <RATABASECALC> <RATEREQUEST> <ANCHOR> <DATABASENAME>DatabaseName</DATABASENAME> <DATABASEPW>DatabasePw</DATABASEPW> </ANCHOR> </RATEREQUEST> </RATABASECALC> Dim xEl1 = XmlWithOutNs...<DATABASEPW>.FirstOrDefault If xEl1 IsNot Nothing Then xEl1.Value = "test" End If However, in the below code the xElement (xEl2) returns Nothing. The only difference is the Namespace (xmlns="http://www.cgi.com/Ratabase) 'Example With Namespace Dim XmlWithNs = _ <?xml version="1.0"?> <RATABASECALC xmlns="http://www.cgi.com/Ratabase"> <RATEREQUEST> <ANCHOR> <DATABASENAME>DatabaseName</DATABASENAME> <DATABASEPW>DatabasePw</DATABASEPW> </ANCHOR> </RATEREQUEST> </RATABASECALC> Dim xEl2 = XmlWithNs...<DATABASEPW>.FirstOrDefault If xEl2 IsNot Nothing Then xEl2.Value = "test" End If So my questions are: 1. Why is this happening? 2. How do I resolve this issue?

    Read the article

  • Call stored proc using xml output from a table

    - by user263097
    Under a tight deadline and I know I can figure this out eventually but I don't have much time to do it on my own. I have a table that has columns for customer id and account number among many other additional columns. There could be many accounts for a single customer (Many rows with the same customer id but different account number). For each customer in the table I need to call a stored procedure and pass data from my table as xml in the following format. Notice that the xml is for all of the customers accounts. <Accounts> <Account> <AccountNumber>12345</AccountNumber> <AccountStatus>Open</AccountStatus> </Account> <Account> <AccountNumber>54321</AccountNumber> <AccountStatus>Closed</AccountStatus> </Account> </Accounts> So I guess I need help with 2 things. First, how to get the data in this xml format. I assuming I'll use some variation of FOR XML. The other thing is how do I group by customer id and then call a sproc for each customer id?

    Read the article

  • How do I insert XML into another XML file with XSLT?

    - by Sandra
    Hello, I looked at this thread to find out how to insert XML into XML with XSLT http://stackoverflow.com/questions/862954/insert-xml-node-at-a-specific-position-of-an-existing-document But I have a problem since I need to insert XML between two grand child nodes. For example I want to insert <s>...</s> between <r>...</r> and <t>...</t> in this file <root> <child1> <a>...</a> <r>...</r> <t>...</t> <z>...</z> </child1> </root> to create this file <root> <child1> <a>...</a> <r>...</r> <s>...</s> <t>...</t> <z>...</z> </child1> </root> Thanks for your help.

    Read the article

  • Java - Image encoding in XML

    - by Hoopla
    Hi everyone, I thought I would find a solution to this problem relatively easily, but here I am calling upon the help from ye gods to pull me out of this conundrum. So, I've got an image and I want to store it in an XML document using Java. I have previously achieved this in VisualBasic by saving the image to a stream, converting the stream to an array, and then VB's xml class was able to encode the array as a base64 string. But, after a couple of hours of scouring the net for an equivalent solution in Java, I've come back empty handed. The only success I have had has been by: import it.sauronsoftware.base64.*; import java.awt.image.BufferedImage; import org.w3c.dom.*; ... BufferedImage img; Element node; ... java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream(); ImageIO.write(img, "png", os); byte[] array = Base64.encode(os.toByteArray()); String ss = arrayToString(array, ","); node.setTextContent(ss); ... private static String arrayToString(byte[] a, String separator) { StringBuffer result = new StringBuffer(); if (a.length > 0) { result.append(a[0]); for (int i=1; i<a.length; i++) { result.append(separator); result.append(a[i]); } } return result.toString(); } Which is okay I guess, but reversing the process to get it back to an image when I load the XML file has proved impossible. If anyone has a better way to encode/decode an image in an XML file, please step forward, even if it's just a link to another thread that would be fine. Cheers in advance, Hoopla.

    Read the article

  • Display attribute from XML using PHP

    - by user560411
    Hello. I need to display the id attribute of CD from the following XML file. I display correctly everything except the id. Any help would be appreciate. display code <?php $doc = new DOMDocument(); $doc->load( 'insert.xml' ); $CATEGORIES = $doc->getElementsByTagName( "CD" ); foreach( $CATEGORIES as $CD ) { $TITLES = $CD->getElementsByTagName( "TITLE" ); $TITLE = $TITLES->item(0)->nodeValue; $BANDS= $CD->getElementsByTagName( "BAND" ); $BAND= $BANDS->item(0)->nodeValue; $YEARS = $CD->getElementsByTagName( "YEAR" ); $YEAR = $YEARS->item(0)->nodeValue; echo "<b>$TITLE - $BAND - $YEAR\n</b><br>"; } ?> XML <?xml version="1.0" encoding="utf-8"?> <MY_CD> <CATEGORIES> <CD id="3231"> <TITLE>NEVER MIND THE BOLLOCKS</TITLE> <BAND>SEX PISTOLS</BAND> <YEAR>1977</YEAR> </CD> <CD id="2453"> <TITLE>NEVERMIND</TITLE> <BAND>NIRVANA</BAND> <YEAR>1991</YEAR> </CD> </CATEGORIES> </MY_CD>

    Read the article

  • Updating DIV with XML content on Hover (JQuery)

    - by Andrew Parisi
    Hi everyone! The concept of what I'm trying to do is fairly simple. I have a grid of company logos loaded through XSLT from an XML document, each with their own unique links to the company profiles. I have a separate div on the page, essentially a "preview" box. What I want to do is this: I roll over a logo, and it loads the name of the company and a short description into the preview div. This content is loaded through XML. I have been messing around with the Jquery load() function, changing the target document to load on Hover—and it almost gets what I want, but it loads the whole target XML document into the div. How can I separate this target XML data into separate divs? (which I have styled differently) I'd assume I would make use of Ajax in some way. I want to load the <name> node into the name_div, and the <desc> node into the description_div, and have them update on hover. Thanks in advance for the help!

    Read the article

  • Xml updating with linq not working when quering

    - by user1734230
    I have problem i'm trying to update a specific part of the XML with the linq query but it doesn't work. So i an xml file: <?xml version="1.0" encoding="utf-8"?> <DesignConfiguration> <Design name="CSF_Packages"> <SourceFolder>C:\CSF_Packages</SourceFolder> <DestinationFolder>C:\Documents and Settings\xxx</DestinationFolder> <CopyLookups>True</CopyLookups> <CopyImages>False</CopyImages> <ImageSourceFolder>None</ImageSourceFolder> <ImageDesinationFolder>None</ImageDesinationFolder> </Design> </DesignConfiguration> I want to select the part where the part where there is Design name="somethning" and get the descendants and then update the descendants value that means this part: <SourceFolder>C:\CSF_Packages</SourceFolder> <DestinationFolder>C:\Documents and Settings\xxx</DestinationFolder> <CopyLookups>True</CopyLookups> <CopyImages>False</CopyImages> <ImageSourceFolder>None</ImageSourceFolder> <ImageDesinationFolder>None</ImageDesinationFolder> I have this code: XDocument configXml = XDocument.Load(configXMLFileName); var updateData = configXml.Descendants("DesignConfiguration").Elements().Where(el => el.Name == "Design" && el.Attribute("name").Value.Equals("AFP_GRAFIKA")).FirstOrDefault(); configXml.Save(configXMLFileName); I'm getting the null data in the updateData varibale. When I'm trying the Descendat's function through QuickWatch it also returns a null value. When I'm checking the configXML variable it has data that is my whole xml. What am I doing wrong?

    Read the article

  • Android XML Parser isnt working

    - by Bram
    I am writing an android application with a XML parser. I have a parser that used to work but when I run it it isnt doing anything. This is my class: import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import android.app.Activity; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class XMLParsingUsingDomeActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(1); TextView ID[]; TextView vraag[]; TextView category[]; TextView a1[]; TextView p1[]; TextView a2[]; TextView p2[]; TextView a3[]; TextView p3[]; try { URL url = new URL( "http://128.140.217.126/vragen.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder dbu= dbf.newDocumentBuilder(); Document doc = dbu.parse(new InputSource(url.openStream())); doc.getDocumentElement().normalize(); NodeList nodeList = doc.getElementsByTagName("item"); ID = new TextView[nodeList.getLength()]; vraag = new TextView[nodeList.getLength()]; category = new TextView[nodeList.getLength()]; a1 = new TextView[nodeList.getLength()]; p1 = new TextView[nodeList.getLength()]; a2 = new TextView[nodeList.getLength()]; p2 = new TextView[nodeList.getLength()]; a3 = new TextView[nodeList.getLength()]; p3 = new TextView[nodeList.getLength()]; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); ID[i] = new TextView(this); vraag[i] = new TextView(this); category[i] = new TextView(this); a1[i] = new TextView(this); p1[i] = new TextView(this); a2[i] = new TextView(this); p2[i] = new TextView(this); a3[i] = new TextView(this); p3[i] = new TextView(this); Element fstElmnt = (Element) node; NodeList nameList = fstElmnt.getElementsByTagName("ID"); Element nameElement = (Element) nameList.item(0); nameList = nameElement.getChildNodes(); ID[i].setText(((Node) nameList.item(0)).getNodeValue()); NodeList vraagList = fstElmnt.getElementsByTagName("vraag"); Element vraagElement = (Element) vraagList.item(0); vraagList = vraagElement.getChildNodes(); vraag[i].setText(((Node) vraagList.item(0)).getNodeValue()); NodeList a1List = fstElmnt.getElementsByTagName("a1"); Element a1Element = (Element) a1List.item(0); a1List = a1Element.getChildNodes(); a1[i].setText(((Node) a1List.item(0)).getNodeValue()); NodeList p1List = fstElmnt.getElementsByTagName("p1"); Element p1Element = (Element) p1List.item(0); p1List = p1Element.getChildNodes(); p1[i].setText(((Node) p1List.item(0)).getNodeValue()); NodeList a2List = fstElmnt.getElementsByTagName("a2"); Element a2Element = (Element) a2List.item(0); a2List = a2Element.getChildNodes(); a2[i].setText(((Node) a2List.item(0)).getNodeValue()); NodeList p2List = fstElmnt.getElementsByTagName("p2"); Element p2Element = (Element) p2List.item(0); p2List = p2Element.getChildNodes(); p2[i].setText(((Node) p2List.item(0)).getNodeValue()); NodeList a3List = fstElmnt.getElementsByTagName("a3"); Element a3Element = (Element) a3List.item(0); a3List = a3Element.getChildNodes(); a3[i].setText(((Node) a3List.item(0)).getNodeValue()); NodeList p3List = fstElmnt.getElementsByTagName("p3"); Element p3Element = (Element) p3List.item(0); p3List = p3Element.getChildNodes(); p3[i].setText(((Node) p3List.item(0)).getNodeValue()); layout.addView(category[i]); Toast.makeText(this, "ID: " + i + "\n" + "Vraag: " + ((Node) vraagList.item(0)).getNodeValue() + "\n" + "A1: " + ((Node) a1List.item(0)).getNodeValue() + "\n" + "P2: " + ((Node) p1List.item(0)).getNodeValue() + "\n" + "A2: " + ((Node) a2List.item(0)).getNodeValue() + "\n" + "P2: " + ((Node) p2List.item(0)).getNodeValue() + "\n" + "A3: " + ((Node) a3List.item(0)).getNodeValue() + "\n" + "P3: " + ((Node) p3List.item(0)).getNodeValue(), Toast.LENGTH_LONG).show(); } } catch (Exception e) { System.out.println("XML Pasing Excpetion = " + e); } /** Set the layout view to display */ setContentView(layout); } } And my manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.pace.namace" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".XMLParsingUsingDomeActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> And the logcat output is worthless. I didnt change the code but its just not working anymore.

    Read the article

  • How to use batch rendering with an entity component system?

    - by Kiril
    I have an entity component system and a 2D rendering engine. Because I have a lot of repeating sprites (the entities are non-animated, the background is tile based) I would really like to use batch rendering to reduce calls to the drawing routine. What would be the best way to integrate this with an engtity system? I thought about creating and populating the sprite batche every frame update, but that will probably be very slow. A better way would be to add a reference to an entity's quad to the sprite batch at initialization, but that would mean that the entity factory has to be aware of the Rendering System or that the sprite batch has to be a component of some Cache entity. One case violates encapsulation pretty heavily, while the other forces a non-game object entity in the entity system, which I am not sure I like a lot. As for engine, I am using Love2D (Love2D website) and FEZ ( FEZ website) as entity system(so everything is in Lua). I am more interested in a generic pattern of how to properly implement that rather than a language/library specific solution. Thanks in advance!

    Read the article

  • xmlns='' was not expected when deserializing nested classes

    - by Mavrik
    I have a problem when attempting to serialize class on a server, send it to the client and deserialize is on the destination. On the server I have the following two classes: [XmlRoot("StatusUpdate")] public class GameStatusUpdate { public GameStatusUpdate() {} public GameStatusUpdate(Player[] players, Command command) { this.Players = players; this.Update = command; } [XmlArray("Players")] public Player[] Players { get; set; } [XmlElement("Command")] public Command Update { get; set; } } and [XmlRoot("Player")] public class Player { public Player() {} public Player(PlayerColors color) { Color = color; ... } [XmlAttribute("Color")] public PlayerColors Color { get; set; } [XmlAttribute("X")] public int X { get; set; } [XmlAttribute("Y")] public int Y { get; set; } } (The missing types are all enums). This generates the following XML on serialization: <?xml version="1.0" encoding="utf-16"?> <StatusUpdate> <Players> <Player Color="Cyan" X="67" Y="32" /> </Players> <Command>StartGame</Command> </StatusUpdate> On the client side, I'm attempting to deserialize that into following classes: [XmlRoot("StatusUpdate")] public class StatusUpdate { public StatusUpdate() { } [XmlArray("Players")] [XmlArrayItem("Player")] public PlayerInfo[] Players { get; set; } [XmlElement("Command")] public Command Update { get; set; } } and [XmlRoot("Player")] public class PlayerInfo { public PlayerInfo() { } [XmlAttribute("X")] public int X { get; set; } [XmlAttribute("Y")] public int Y { get; set; } [XmlAttribute("Color")] public PlayerColor Color { get; set; } } However, the deserializer throws an exception: There is an error in XML document (2, 2). <StatusUpdate xmlns=''> was not expected. What am I missing or doing wrong? EDIT: On request I'm also adding code used to serialize and deserialize: Server: public static byte[] SerializeObject(Object obj) { XmlSerializer xmlSerializer = new XmlSerializer(obj.GetType()); StringWriter writer = new StringWriter(); // Clear pre-defined namespaces XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("", ""); xmlSerializer.Serialize(writer, obj, xsn); writer.Flush(); // Send as little-endian UTF-16 string because the Serializer denotes XML as // utf-18 which cannot be easly changed UnicodeEncoding encoder = new UnicodeEncoding(false, false); return encoder.GetBytes(writer.ToString()); } Client: public static object DeserializeXml(string xmlData, Type type) { XmlSerializer xmlSerializer = new XmlSerializer(type); StringReader reader = new StringReader(xmlData); object obj = xmlSerializer.Deserialize(reader); return obj; } Deserialization is invoked with StatusUpdate update = (StatusUpdate) Util.DeserializeXml(xmlData, typeof (StatusUpdate));

    Read the article

  • How change Castor mapping to remove "xmlns:xsi" and "xsi:type" attributes from element in XML output

    - by Derek Mahar
    How do I change the Castor mapping <?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd"> <mapping> <class name="java.util.ArrayList" auto-complete="true"> <map-to xml="ArrayList" /> </class> <class name="com.db.spgit.abstrack.ws.response.UserResponse"> <map-to xml="UserResponse" /> <field name="id" type="java.lang.String"> <bind-xml name="id" node="element" /> </field> <field name="deleted" type="boolean"> <bind-xml name="deleted" node="element" /> </field> <field name="name" type="java.lang.String"> <bind-xml name="name" node="element" /> </field> <field name="typeId" type="java.lang.Integer"> <bind-xml name="typeId" node="element" /> </field> <field name="regionId" type="java.lang.Integer"> <bind-xml name="regionId" node="element" /> </field> <field name="regionName" type="java.lang.String"> <bind-xml name="regionName" node="element" /> </field> </class> </mapping> to suppress the xmlns:xsi and xsi:type attributes in the element of the XML output? For example, instead of the output XML <?xml version="1.0" encoding="UTF-8"?> <ArrayList> <UserResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="UserResponse"> <name>Tester</name> <typeId>1</typeId> <regionId>2</regionId> <regionName>US</regionName> </UserResponse> </ArrayList> I'd prefer <?xml version="1.0" encoding="UTF-8"?> <ArrayList> <UserResponse> <name>Tester</name> <typeId>1</typeId> <regionId>2</regionId> <regionName>US</regionName> </UserResponse> </ArrayList> such that the element name implies the xsi:type.

    Read the article

< Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >