XML

One of the useful tool for visualization of RDF data is WebVOWL - http://visualdataweb.de/webvowl/. It supports RDF data in XML as well as in Turtle (TTL) formats and allows complex visualization of data.

Technology:

Use Notepad++ to view and edit XML documents

Notepad++ is a free source code editor and Notepad replacement that supports several formats. In its basic edition it can already do some nice things like:

  • collapse structured texts like XML on a certain hierarchy level with the key combination "Alt"+X, where X is a number between 1 and 8. Uncollapse with "Shift"+"Alt"+X.
  • Extended search and replace with e.g. line breaks or search and replace using regular expressions.
  • Vertical selection and simultaneous editing of text holding down the "Alt" key.
  • and many more...
  • If you download the XML Tools Plugin you can also pretty print XML documents without witespaces. Just select it from the plugins menu or use the keyboard shortcut "Ctrl"+"Alt"+"Shift"+"B". Check out also the other features provided with the plugin.

    Taggings:

    How to reset font size formatting in XML/InfoPath file with c#

    First of all we have to load the complet XML structures (root of XML Shema) in a variable.
    Then wo do a search for the "font" tag and "/font" tag and replace it with an empty string.


    public void resetfontsize()
    {
    // XPath to tho root of the XML Shema
    string xml_data = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:Befund",NamespaceManager).InnerXml;
    // set the Index of the searcher = 1
    int nextindex = 1;
    //if the search index greater than 0 --> make the search
    while (nextindex > 0)
    {
    //serach for open tag font
    nextindex = xml_data.IndexOf(" 0)
    {
    //search for close tag
    int nextklammer = xml_data.IndexOf(">", nextindex);
    string replstring = xml_data.Substring(nextindex, nextklammer - nextindex + 1);
    //replace the result with empty string
    xml_data = xml_data.Replace(replstring, "");
    }
    }
    xml_data = xml_data.Replace("", "");
    this.MainDataSource.CreateNavigator().SelectSingleNode("/my:Befund", NamespaceManager).InnerXml = xml_data;
    }

    Taggings:

    Wiener Linien API

    The challenge was to get a public transport route, by sending time, date, start and destination address. The problem was solved by using the "Wiener Linien API" (http://akirk.github.com/Wiener-Linien-API/). The PHP-Code sends a XML-request with all details of the appointment and get a XML-respond with the transport connection.

    For building a request the PHP-function "buildRequest()" can be used.
    The following example illustrates a query from "Seckendorfstrasse 4" to "Wiedner Hauptstr. 8":

    $params = array();
    $params["outputCoords"] = "WGS84";
    $params["from"] = "Seckendorfstrasse 4";
    $params["to"] = "Wiedner Hauptstr. 8";
    $params["year"] = "2011";
    $params["month"] = "12";
    $params["day"] = "14";
    $params["hour"] = "17";
    $params["minute"] = "00";
    $params["deparr"] = "arr";
    $params["modality"] = "pt";
    $params["sourceFrom"] = "gps";
    $params["sourceTo"] = "stoplist";
    $req = buildRequest("api_get_route", $params);

    Afterwards, the XML-request must be sent to the following webservice: http://webservice.qando.at/2.0/webservice.ft.

    $response = httpPost("http://webservice.qando.at/2.0/webservice.ft", $req);

    Finally, the XML-response must be load into a Document Object Model (DOM). A DOM presents an XML document as a tree-structure, which makes it easy to interpret and evaluate the local public transport route.

    $dom = new DOMDocument();
    $dom->formatOutput = true;
    $dom->preserveWhiteSpace = false;
    $dom->loadXML($response);

    The complete DOMDocument manual is available on the website: http://php.net/manual/de/class.domdocument.php.

    To print out the XML-response of the public transport route, use the following PHP-code:

    echo "Response: " .$dom->saveXML(). "";

    Taggings:

    Application.LoadCusomUI + xml description

    To implement a custom Ribbon element we have to describe it using an XML file defined by the Microsoft CustomUI schema and load it using the Application.LoadCustomUI() procedure.

    The root element of the XML file is customUI. Inside of it there is the element ribbon containing all the tabs, buttons etc.

    A code snippet for loading of the xml file:

    Dim f As Long
    Dim strText As String
    Dim strOut As String

    f = FreeFile
    Open "\customUI.xml" For Input As f

    Do While Not EOF(f)
    Line Input #f, strText
    strOut = strOut & strText
    Loop

    Application.LoadCustomUI "AppRibbon_1", strOut

    Sample XML file:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="false">
    <tabs>
    <tab id="Tab1" label="Tab1">
    <group id="Group" label="Group">
    <button id="MyButton1" label="Button1" imageMso="_1"
    onAction="doSomeAction"/>
    <button id="MyButton2" label="Button2" imageMso="_2"
    onAction="doSomeAction2"/>
    </group>
    <group id="Group2" label="Group2">
    <button id="MyButton3" label="Button3" imageMso="_1"
    onAction="doSomeAction3"/>
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI>

    Taggings:

    Converting XML to JSON and JSON to XML by using Javascript or Java

     There are several tested solutions available on the Internet already: JAVASCRIPT Solution approach:  It provides 

    • XML to JSON

       Download Skript: http://www.thomasfrank.se/downloadableJS/xml2json.js  Usage as documented on this site: <head><script type="text/javascript" src="xml2json.js"></script>...</head>Then it can be called in these different variants: 

    1. V1: /*A simple call - myXML is a string containing your XML:*/ myJsonObject=xml2json.parser(myXML);
    2. V2: /*A 2:nd, optional, parameter is "tags not to convert" - for example <b> and <i>:*/ myJsonObject=xml2json.parser(myXML,'b,i')
    3. V3: /*A 3:rd, optional, parameter gives us a string showing us the JSON structure instead of the actual JSON object: */ myString=xml2json.parser(myXML,'','html');

     V1 ("compact") can be used for output without linebreaks or tabbing. V2 for normal output with linebreaks ant tabbing. V3 for HTML representation.JAVA solution approach  (which is solution I have already tested and which is provided by Json.org):    The Source files are available at http://json.org/java/ for many JSON issues in Java.    The relevant class is called XML and is viewable at:  

      It provides 

    • XML to JSON
    • JSON to XML

     

    1. Create your class
    2. Import org.json.XML;
    3. Prepare an xml input value: String xmlValue = "<..>";
    4. /*XML to JSON*/ Type: JSONObject jsonResult = XML.toJSONObject(xmlValue);
    5. /*JSON to XML*/ Type: String xmlResult = XML.toString(jsonResult);

      Naturally, the XML has to be well-formed and valid to produce a JSON object. The JSON objcect istself has to be valid again. It can be assumed that always correct outputs for valid inputs are retrieved according its high adoption in real world usage. 

    Taggings:

    json - an alternative to xml

    json can be seen as a light-weight alternative to XML.

    http://www.json.org/index.html
    JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.

    It is just a very minimalistic generic serialization method of data-structures (objects, lists, or however you call it), so it can be used within (or between) virtually any language(s), but as it is a subset of JavaScript, it is especially suited for use in JavaScript applications and being much leaner (schlanker) than XML it is the interchange-format of choice for AJAX-applications,
    which is the explicit main purpose of this format.

    Taggings:

    Subscribe to XML