Affichage des articles dont le libellé est Active questions tagged xml - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged xml - Stack Overflow. Afficher tous les articles

mardi 4 août 2015

XNA / Monogame Texture2D to to string

I want to store a small png image in a XML file and Load it back to Texture2D.

This is what I'm doing

Code for saving

I'm writing the data of the Texture2D with the BinaryWriter to a MemoryStream,

then converting the MemoryStream to an Array. I have to Convert the array to a Base64String because you can't save all characters

in a XML file.

The string is saved in my XML file.

    public static string SaveTextureData(this Texture2D texture)
    {
        int width = texture.Width;
        int height = texture.Height;
        Color[] data = new Color[width * height];
        texture.GetData<Color>(data, 0, data.Length);

        MemoryStream streamOut = new MemoryStream();

        BinaryWriter writer = new BinaryWriter(streamOut);

           writer.Write(width);
            writer.Write(height);
            writer.Write(data.Length);

            for (int i = 0; i < data.Length; i++)
            {
                writer.Write(data[i].R);
                writer.Write(data[i].G);
                writer.Write(data[i].B);
                writer.Write(data[i].A);
            } 

        return Convert.ToBase64String(streamOut.ToArray());
    }

Code for Loading

Same here.. I'm converting the Base64Str to an array and trying to read it.

But I cant read it back.

    public static Texture2D LoadTextureData(this string gfxdata, GraphicsDevice gfxdev)
    {
        byte[] arr = Convert.FromBase64String(gfxdata);

        MemoryStream input = new MemoryStream();

        BinaryWriter bw = new BinaryWriter(input);
        bw.Write(arr);

        using (BinaryReader reader = new BinaryReader(input))
        {
            var width = reader.ReadInt32();
            var height = reader.ReadInt32();
            var length = reader.ReadInt32();
            var data = new Color[length];

            for (int i = 0; i < data.Length; i++)
            {
                var r = reader.ReadByte();
                var g = reader.ReadByte();
                var b = reader.ReadByte();
                var a = reader.ReadByte();
                data[i] = new Color(r, g, b, a);
            }

            var texture = new Texture2D(gfxdev, width, height);
            texture.SetData<Color>(data, 0, data.Length);
            return texture;
        }
    }

Could need some help here.

Getting an exception in the reading method that the value couldnt read. in line var width = reader.ReadInt32();

R devtools fails as "Package libxml-2.0 was not found in the pkg-config search path"

I am trying to install devtools in R version 3.2.1, however when I do the following error is thrown:

Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing libxml-2.0.pc
to the PKG_CONFIG_PATH environment variable

when I run dpkg -L libxml2-dev in a terminal I find:

/usr
/usr/bin
/usr/bin/xml2-config
/usr/share
/usr/share/aclocal
/usr/share/aclocal/libxml2.m4
/usr/share/doc
/usr/share/doc/libxml2-dev
/usr/share/doc/libxml2-dev/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/xml2-config.1.gz
/usr/share/man/man3
/usr/share/man/man3/libxml.3.gz
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libxml2.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libxml-2.0.pc
/usr/lib/x86_64-linux-gnu/xml2Conf.sh
/usr/include
/usr/include/libxml2
/usr/include/libxml2/libxml
/usr/include/libxml2/libxml/globals.h
/usr/include/libxml2/libxml/schematron.h
/usr/include/libxml2/libxml/xlink.h
/usr/include/libxml2/libxml/HTMLparser.h
/usr/include/libxml2/libxml/pattern.h
/usr/include/libxml2/libxml/xmlexports.h
/usr/include/libxml2/libxml/xmlschemas.h
/usr/include/libxml2/libxml/list.h
/usr/include/libxml2/libxml/entities.h
/usr/include/libxml2/libxml/xmlstring.h
/usr/include/libxml2/libxml/encoding.h
/usr/include/libxml2/libxml/hash.h
/usr/include/libxml2/libxml/xmlmemory.h
/usr/include/libxml2/libxml/relaxng.h
/usr/include/libxml2/libxml/xmlsave.h
/usr/include/libxml2/libxml/SAX2.h
/usr/include/libxml2/libxml/xmlIO.h
/usr/include/libxml2/libxml/xmlschemastypes.h
/usr/include/libxml2/libxml/xpathInternals.h
/usr/include/libxml2/libxml/schemasInternals.h
/usr/include/libxml2/libxml/xmlmodule.h
/usr/include/libxml2/libxml/valid.h
/usr/include/libxml2/libxml/c14n.h
/usr/include/libxml2/libxml/xmlwriter.h
/usr/include/libxml2/libxml/tree.h
/usr/include/libxml2/libxml/xmlunicode.h
/usr/include/libxml2/libxml/nanohttp.h
/usr/include/libxml2/libxml/catalog.h
/usr/include/libxml2/libxml/xmlerror.h
/usr/include/libxml2/libxml/nanoftp.h
/usr/include/libxml2/libxml/xmlautomata.h
/usr/include/libxml2/libxml/xinclude.h
/usr/include/libxml2/libxml/HTMLtree.h
/usr/include/libxml2/libxml/chvalid.h
/usr/include/libxml2/libxml/parserInternals.h
/usr/include/libxml2/libxml/xpointer.h
/usr/include/libxml2/libxml/xmlversion.h
/usr/include/libxml2/libxml/dict.h
/usr/include/libxml2/libxml/xmlregexp.h
/usr/include/libxml2/libxml/DOCBparser.h
/usr/include/libxml2/libxml/parser.h
/usr/include/libxml2/libxml/xmlreader.h
/usr/include/libxml2/libxml/SAX.h
/usr/include/libxml2/libxml/threads.h
/usr/include/libxml2/libxml/debugXML.h
/usr/include/libxml2/libxml/xpath.h
/usr/include/libxml2/libxml/uri.h
/usr/share/doc/libxml2-dev/README
/usr/share/doc/libxml2-dev/NEWS.gz
/usr/share/doc/libxml2-dev/AUTHORS
/usr/share/doc/libxml2-dev/TODO.gz
/usr/share/doc/libxml2-dev/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/libxml2.so

to try and add this to the PKG_CONFIG_PATH I tried: env PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig however this does not seem to work.

How to manipulate a tabbed view in Titanium and add SQLite content?

The Overview

I am fairly new to Titanium and I decided to finally start working with SQLite and some new UI features. I opted for the TabGroup as I felt that would be the best option. However I'm having a few issues. I am trying to simply get some quotes which have been inserted to a table (tested and working, I alerted them out and it worked) and I wish to display them out in the wiseWords tab, so the user can view them.

The Code

index.xml

<Alloy id="index">
    <TabGroup>
        <Require src="home"></Require>
        <Require src="wiseWords"></Require>
        <Require src="settings"></Require>
    </TabGroup>
</Alloy>

index.js

$.index.open(); 

/** Create and populate the wise words table. **/
Alloy.Globals.createRequiredTables();

var selectWiseWordsSQL = "SELECT * FROM wise_words";
var selectWiseWords = Titanium.App.db.execute(selectWiseWordsSQL);

while (selectWiseWords.isValidRow()) {
    /** Create labels for each quote. **/
    var addQuote = Titanium.UI.createLabel({
        text : selectWiseWords.fieldByName("saying") + " - " + selectWiseWords.fieldByName("quoted_by"),
    });

    /** Add quote to window (available in wiseWords.xml). **/
    $.wiseWordsWindow.add(addQuote);

    selectWiseWords.next();
}
selectWiseWords.close();

wiseWords.xml

<Alloy>
    <Tab id="wiseWordsTab" title="Wise Words">
        <Window id="wiseWordsWindow" class="container" title="Wise Words">  
        </Window>
    </Tab>
</Alloy>

The Error(s)

Runetime Error

Location: alloy/controllers/index.js

Uncaught TypeError: Cannot call method 'add' of undefined.

Source: $.wiseWordsWindow.add(addQuote);

To Clarify...

I understand what the error means, but don't understand why it is being thrown.

  1. Why can't I access the view for wiseWords.xml in index.js even though wiseWords is referenced in index.xml through the <Require> tag?

registerClassCommandBinding / Ribbon Class - Binding not firing

I'm trying to implement contextual help, when a button in the Ribbon Class has been selected. Try as I might, I can't seem to get the button firing on the Application Help command via this binding:

            CommandManager.RegisterClassCommandBinding(typeof(UIElement), new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(ShowHelpExecuted),
                   new CanExecuteRoutedEventHandler(ShowHelpCanExecute)));

I've even tried this:

                CommandManager.RegisterClassCommandBinding(typeof(**RibbonToggleButton**), new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(ShowHelpExecuted),
                   new CanExecuteRoutedEventHandler(ShowHelpCanExecute)));

For a direct binding to the button class, but I still don't get called when the Help (F1) button is called.

What does happen is the method is invoked, but the sender of the method is the main from that the control resides on, rather than the actual button that has focus. I want to provide help specific to the control that has focus (in this case the button), rather than just the form that the button resides on.

Here's a portion of the XML for the ribbon until the first toggle button

<Grid Name="GridRibbonBar"
          Grid.Row="0"
          Grid.Column="0"
          IsHitTestVisible="True">


        <Ribbon x:Name="RibbonMain"
                Background="AliceBlue"
                ContextMenu="{x:Null}"
                PreviewMouseLeftButtonDown="RibbonMain_OnPreviewMouseLeftButtonDown"
                ShowQuickAccessToolBarOnTop="False">


            <Ribbon.TitleTemplate>
                <DataTemplate>
                    <TextBlock TextAlignment="Center"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               FontWeight="SemiBold"
                               Width="{Binding ElementName=Window, Path=ActualWidth}"
                               Text="{x:Static p:Resources.Title}">
                        <TextBlock.Effect>
                            <DropShadowEffect ShadowDepth="0"
                                              Color="MintCream "
                                              BlurRadius="10" />
                        </TextBlock.Effect>
                    </TextBlock>
                </DataTemplate>
            </Ribbon.TitleTemplate>

            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu Visibility="Collapsed" />
            </Ribbon.ApplicationMenu>

            <!--Options Tab-->
            <RibbonTab Header="{x:Static p:Resources.treeHdrOptions}"
                       ContextMenu="{x:Null}">
                <RibbonGroup Header="{x:Static p:Resources.ribbonGroupGuestAccount}"
                             Visibility="{Binding Path=LoginViewModel.User.IsOwnerOrPowerOfAttorney,Converter={StaticResource VisibilityConverter},Source={StaticResource ViewModelLocatorService}}"
                             ContextMenu="{x:Null}">
                    <RibbonGroup.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Horizontal"
                                       Width="50" />
                        </ItemsPanelTemplate>
                    </RibbonGroup.ItemsPanel>
                    <RibbonToggleButton Name="guestacount"
                                        Visibility="{Binding Path=LoginViewModel.User.IsOwnerOrPowerOfAttorney,Converter={StaticResource VisibilityConverter},Source={StaticResource ViewModelLocatorService}}"
                                        Label="{x:Static p:Resources.treeGuest}"
                                        SmallImageSource="../images/RibbonIcons/PNGFormat/GeneralGuest.png"
                                        LargeImageSource="../images/RibbonIcons/PNGFormat/GeneralGuest.png"
                                        Checked="RibbonToggleButton_OnChecked"
                                        ContextMenu="{x:Null}" />
                </RibbonGroup>
            </RibbonTab>

Multiple Ribbon XML in one Add-In

I want to have two Ribbon XML in one Outlook Add-In. Ribbon2 is a button in a context menu and Ribbon1 is a tab in Outlook Mail Read. I did this - VSTO - Is it possible to have both designer and XML ribbons?, but then getLabel, getVisible, etc, doesn't work! Can you please help me? Thanks!!

ImageView in SurfaceView without XML

My question is if is possible add an ImageView in a SurfaceView without XML. If yes, how? I have a main class that has the function of GamePanel, and for apply a Method i need to call it with an ImageView, but i don't know if it is possible. Thanks you in advance.

XMLStreamReader how to work with nested elements of same type

I'm working with the XMLStreamReader and parsing the following XML:

<root>
    <element>
        <attribute>level0</attribute>
        <element>
            <attribute>level1</attribute>
            <element>
                <attribute>level2</attribute>
            </element>
        </element>
    </element>
</root>

I'm building out my XMLStreamReader:

XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
                new ByteArrayInputStream(document.getBytes()));

Unfortunately, when I get to the first closing element tag with reader.next();, I get the following exception:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,14]
Message: XML document structures must start and end within the same entity. 

Is there a way to override the default behavior of the XMLStreamReader to get around with this?

Android Application is able to run smoothly but show up blank page

In my database I have 2 tables, table category, and table menu. In the category table, each restaurant has different category(i.e Restaurant1: {category: food, beverage}, Restaurant2: {category: snacks,dessert}. Now I want to retrieve the menu for each category of the selected restaurant as an expandable list. the category name as the group list and the menu in that category as the child list. So far I have managed to retrieve the array of data and tried to use my own custom adapter to create the expandablelist, but the app is able to run but shows a blank page.

MainActivity.java

package com.example.ed.expandablelistview;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class MainActivity extends Activity {

HashMap<String, List<String>> countriesHashMap;
List<String> countriesHashMapKeys;
ExpandableListView expandableListView;
MyCustomAdapter adapter;

private static final String TAG_SUCCESS = "success";
private static final String TAG_CAT_LIST = "cat_list";
private static final String TAG_MENU_LIST = "menu_list";
private static final String TAG_CAT = "category";
private static final String TAG_ITEM = "item";

private static String url_get_menu_list = "http://ift.tt/1N7UEJV";
private static String url_get_cat_list = "http://ift.tt/1VZuYVP";

ArrayList<HashMap<String, String>> catList;

JSONArray menu_list = null;

List<String> catFoodList = new ArrayList<String>();

HashMap<String, List<String>> menuHashMap = new HashMap<String, List<String>>();

JSONParser jParser = new JSONParser();
JSONArray cat_list = null;
String rest_name, rest_pid;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    new ShowMenu().execute();

    expandableListView = (ExpandableListView) findViewById(R.id.expandableList);
    countriesHashMap = menuHashMap;
    countriesHashMapKeys = new ArrayList<String>(countriesHashMap.keySet());

    adapter = new MyCustomAdapter(this, countriesHashMap, countriesHashMapKeys);
    expandableListView.setAdapter(adapter);

}

public class ShowMenu extends AsyncTask<String, HashMap<String, List<String>>, String> {

    protected String doInBackground(String... args) {

        rest_name = "Restaurant";
        rest_pid = "2";

        catList = new ArrayList<HashMap<String, String>>();

        //building params
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("rest", rest_name));
        params.add(new BasicNameValuePair("pid", rest_pid));

        //getting JSON string from url
        JSONObject json = jParser.makeHttpRequest(url_get_cat_list, "GET", params);

        //check log cat for response
        Log.d("Menu : ", json.toString());

        //Get Array of category list
        try {
            //check for success tag
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                //get array of menu
                cat_list = json.getJSONArray(TAG_CAT_LIST);

                //looping through all cat_list
                for (int i = 0; i < cat_list.length(); i++) {
                    JSONObject c = cat_list.getJSONObject(i);

                    //storing each json in variable
                    String category = c.getString(TAG_CAT);

                    //creating new hashmap
                    HashMap<String, String> map = new HashMap<String, String>();

                    //adding each child node to hashmap key => value
                    map.put(TAG_CAT, category);

                    //add hashlist to arraylist
                    catList.add(map);

                    //Build params to get menu of category
                    List<NameValuePair> mparams = new ArrayList<NameValuePair>();
                    mparams.add(new BasicNameValuePair("get_cat", category));
                    mparams.add(new BasicNameValuePair("get_pid", rest_pid));

                    //get menu of category
                    JSONObject menujson = jParser.makeHttpRequest(url_get_menu_list, "GET", mparams);

                    //check log cat for response
                    Log.d("Menu : ", menujson.toString());

                    try {
                        //check for success tag
                        int msuccess = menujson.getInt(TAG_SUCCESS);

                        if (msuccess == 1) {
                            //get array of menu
                            menu_list = json.getJSONArray(TAG_MENU_LIST);

                            for (int m = 0; m < menu_list.length(); m++) {
                                JSONObject l = menu_list.getJSONObject(m);
                                String item = l.getString(TAG_ITEM);
                                catFoodList.add(item);
                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    menuHashMap.put(category, catFoodList);

                }
            } else {
                //no category found
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;

    }
}

}

MyCustomAdapter.java

package com.example.ed.expandablelistview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;


public class MyCustomAdapter extends BaseExpandableListAdapter {

private Context context;
private HashMap<String, List<String>> countriesHashMap;
private List<String> countryList;

public MyCustomAdapter(Context context,
                       HashMap<String, List<String>> hashMap,
                       List<String> list) {
    countriesHashMap = hashMap;
    this.context = context;
    this.countriesHashMap = hashMap;
    this.countryList = list;
}

@Override
public int getGroupCount() {
    return countriesHashMap.size();
}

@Override
public int getChildrenCount(int groupPosition) {
    return countriesHashMap.get(countryList.get(groupPosition)).size();
}

@Override
public Object getGroup(int groupPosition) {
    return countryList.get(groupPosition);
}

@Override
public Object getChild(int groupPosition, int childPosition) {
    return countriesHashMap.get(countryList.get(groupPosition)).get(childPosition);
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    String groupTitle = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater inflater =
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.parent_layout, parent, false);
    }
    TextView parentTextView = (TextView) convertView.findViewById(R.id.textViewParent);
    parentTextView.setText(groupTitle);
    return convertView;
}

@Override
public View getChildView(int groupPosition,
                         int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {
    String childTitle = (String) getChild(groupPosition, childPosition);
    if(convertView == null) {
        LayoutInflater inflater =
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.child_layout, parent, false);
    }
    TextView childTextView = (TextView) convertView.findViewById(R.id.textViewChild);
    childTextView.setText(childTitle);
    TextView childTextView2 = (TextView) convertView.findViewById(R.id.textViewChild2);
    childTextView2.setText("test");
    return convertView;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}
}

activity_main.xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<ExpandableListView
    android:id="@+id/expandableList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@color/green"
    android:dividerHeight="10dp"
    android:indicatorLeft="?android:attr/expandableListPreferredItemIndicatorLeft"
    ></ExpandableListView>

</RelativeLayout>

parent_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
    android:id="@+id/textViewParent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
    android:paddingTop="10dp"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/red"
    android:textStyle="bold"/>

</LinearLayout>

child_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
android:id="@+id/textViewChild"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/orange_dark"
android:gravity="center_horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/white"
/>

</LinearLayout>

I have managed to retrieve the data of the category and the menu from my database as an array, which I put in the hashmap and use the adapter to the expandablelist, but the app shows blank page. All answers and suggestions are greatly welcomed. Thanks in advance.

Two relatives, same height

I have two RelativeLayouts (one next to each other). A White RelativeLayout and red RelativeLayout. As the amount of the text of the white side increases, I want the the red side grow.

what is the best data model to represent mathematical range (in database,xml,json...)?

mathematical range,for example:

greater or equal to 50 and smaller than 100 (>=50 && < 100)

smaller than 10 or greater than 40 (<10 || >40)

I have been thinking about how to represent mathematical range in a file and database, the range may be input by non programmer and I need to keep the input simple,but at another side, it also need to keep the input easy to convert to data and easy to check error input e.g.:"<10 || >100" seems the most simple but it is harder for me to parse the string to get the data,also need to consider input format error

I have been considering some input methods,using >=50 && < 100 as example,which is in key value form:

1.using 1 string to represent whole range:

<rangeInString>=50 && < 100</rangeInString>

2.separate 2 strings,one represent lower bound and another one represent upper bound,then parse each string in program:

<lowerBound> >=50 </lowerBound>
<upperBound> <100 </upperBound>

3.separate lower and upper bound,also separate the sign from number:

<lowerBound>
    <sign> >= </sign>
    <data>50</data>
</lowerBound>
<upperBound>
    <sign> < </sign>
    <data>100</data>
</upperBound>

4.separate lower bound and upper bound,also separate sign, and also separate the case that if includes the equal condition:

<lowerBound>
    <sign> > </sign>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</lowerBound>
<upperBound>
    <sign> < </sign>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</upperBound>

5.auto detect using "&&" or "||",e.g.:>= A with < B,if A < B,must be "&&" e.g.(>= 50 && <100),otherwise it is "||" e.g.(>= 100 || <50):

<A>
    <sign> > </sign>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</A>
<B>
    <sign> < </sign>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</B>

6.use a field "isAnd" to separate >=50 && < 100 (true) and <=50 || > 100 (false)instead of using field sign "<" and ">" :

<lowerBound>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</lowerBound>
<upperBound>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</upperBound>
<isAnd>true</isAnd>

7.other data model...

I need to consider somethings:

1.easy for non programmer to input

2.easy to convert or parse to data into program

3.easy to check error ,for example,parse string increase the complexity of converting data and checking incorrect format,also there may have other incorrect format,e.g.:<=50 && >100 should not be valid, I may allow auto detect using "&&" or "||" by the sign of input,but it may increase the complexity of the code

can anyone have idea?

Which one better for XML data Mongodb or orientdb

I cannot use an XML base database. Have to choose from mongo DB or orient DB. Which one will be more suitable for XML based data. where I can directly save or fetch XMLs, run xpath, jquery.

XML5617: Illegal XML character in IE9

My applications is working in IE11, Chrome but not in IE9. It gives XML5617: Illegal XML character error, but there is no illegal character, other wise it will not work in IE11 and Chrome. I am using Ajax to load the data. I am lost. Thanks for help.

Also it works in IE9 for english language customers but not for non-english.

Python “Walk” directory to deal with xml

I'm a new comer about python, and I code this program to deal with xml in os.walk(). This program can print "channel code" from different xml files, and they all named "mmiap.xml".

It is the code:

#coding=utf-8
import os
import  xml.dom.minidom


path = "H:\\Dev\\CODE\\MMwithwalk\\"

for root, dirs,files in os.walk(path):

    dom = xml.dom.minidom.parse('mmiap.xml')

    root = dom.documentElement

    bb = root.getElementsByTagName('channel')   #Get channel code from mmiap.xml

    b= bb[0]

    print (b.firstChild.data)

After run this program, it shows "FileNotFoundError: [Errno 2] No such file or directory: 'mmiap.xml'"

What's wrong? It seems that traversal is not walk depth. But I can't find the problem.

PS: If I drag a mmiap.xml to root directory, channel code will be printed normally.

Trouble matching a regex part of an XML with java

Hello I got a problem using the regex with Java.

I'm trying to parse this :

*whatever string*
<AttributeDesignator AttributeId="MyIDToParse"
DataType="http://ift.tt/QHQMAU"
Category="theCategoryIWantToParse"
MustBePresent="false"
/>
*whatever string that may contain the same regular expression*

using this code (Pattern + Matcher)

Pattern regex = Pattern.compile("AttributeDesignator +AttributeId=\"(.+)\" +.*Category=\"(.+)", Pattern.DOTALL);
Matcher matcher = regex.matcher(xml);
while (matcher.find()) {
    String ID = matcher.group(1);
    String Category = matcher.group(2);

The output is the following :

group 1 :

MyIDToParse"
    DataType="http://ift.tt/QHQMAU"
    Category="theCategoryIWantToParse"
    MustBePresent="false"
    />
    *whatever string that may contain the same regular expression*

group2 :

theCategoryIWantToParse"
    MustBePresent="false"
    />
    *whatever string that may contain the same regular expression*

I feel like it's a simple thing but I can't find whatever I'm doing wrong.. When I used the regex in a website to test them it works correctly and highlight the right expression from my xml entry.

Line breaks in PHP xmlwriter document

I've got an XML feed I've created using XMLWriter. It works flawlessly in dev on a PHP 5.6 vagrant box. On the live server, running PHP 5.4 the feed fails to render with a message:

This page contains the following errors:

error on line 3 at column 6: XML declaration allowed only at the start of the document

If you view source it looks like this:

source

Somehow there are a couple lines being added into the XML document. The only difference between the servers is the PHP version (as far as I know).

Here's the first few lines of the XMLWriter code:

$xml = new XMLWriter();
$xml->openURI('php://output');
$xml->startDocument("1.0");
$xml->setIndent(true);
$xml->startElement("propertyList");
$xml->writeAttribute('date', date('Y-m-d-H:i:s'));

Any ideas how to get around this?

Extraction of data from Soap Response in Php

I did a SOAP/WSDL request with a PHP script. I could access an answer which look like this :

stdClass Object
(
     [inventory] => Array[inventory] => Array
     (
        [0] => stdClass Object
               (
                [location_inventory] => stdClass Object
                    (
                        [location] => stdClass Object
                            (
                                [organization] => abcdef
                                [contact] => stdClass Object
                                    (
                                        [contact_details] => stdClass Object
                                            (
                                                [id] => Thomas
                                            )
                                    )
                            )
                        [product] => tomatoes
                    )
            )
    )
)

The point is that I can't extract the variables "organization", "id", or "product".

What is the difference of syntax when accessing a stdClass Object or an Array ?

Google Sheet - Imported XML Content Parse Error

Even though Google has now fixed the Importxml error with the new Google sheets, I am still having problems with the below query:

=IMPORTXML("http://ift.tt/1VZhqK1","/progressives//game table[1]@jackpot")

Any ideas why this could be?

cheers!

Xpath Contains Query on child node to return Parent node

String query = null;
XPathExpression expr;
Object Result = null;

expr = xpath.compile("//table/column[contains(translate(text(),'ABCDEFGHIJKLMNAOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'"+query+"')]//text()");

result = expr.evaluate(doc, XpathConstants.NODESET);

NodeList nodes = (NodeList) result;

for (int i = 0; i<nodes.getLength(); i++){
     System.out.println(nodes.item(i).getParentNode().getNodeName() + "" + nodes.item(i).getNodeValue());
}

Hi, so I want to start off by saying I am new to xpath and fairly new to java. I am trying to create a query interface for this large xml file and this is what I have come up with so far. The xml file is full of logs and it is setup somewhat like this.... ..... The code works well at pulling back the column that match the search term however I would like it to pull back the whole table and then print it out. this will give me more valuable info including the date stamp the person who entered it ect.... I have tried various things from trying to get the parentnode from nodes(i) then putting the .getchildnodes into another nodelist but that didn't work at all. I also tried adding /.. at the end of the xpath before the text() to see if it would give me back the parent but that ended up just giving me the root tag somehow. I think I am kinda close, maybe not I don't know but if anyone can help that would be much appreciated, I have been stuck on this for a while now.

best way to compare xml data's and present that to user as HTML

Consider the following two different xml based result/response, all follow same xsd in general

    xml1: 
    <student name="1" rollNo="1">
        <result>
            <subject name="lang" marks=90/>
            <subject name="science" marks=80/>
            <subject name="maths" marks=95/>
        </result>
    </student>

    xml2: 
    <student name="2" rollNo="2">
        <result>
            <subject name="lang" marks=100/>
            <subject name="science" marks=90/>
            <subject name="maths" marks=90/>
        </result>
    </student>

    Expected Comparison HTML:

    Students Result:
    ------------------------------------
            |        Subjects           |
    Roll No |---------------------------
            | lang  | science   | maths |   
    -------------------------------------
    1       | 90   |    80      | 95    |   
    2       | 100  |    90      | 90    |
    -------------------------------------

Also consider the future cases like, if the xml evolves with more added details

    <student name="1" rollNo="1">
        <result>
            <subject name="lang">
                <internal =50>
                <external =40>
            </subject>
            ....
        </result>
    </student>

then the table should also presented like

    ----------------------------------------------
            |        Subjects                    |
    Roll No |-------------------------------------
            | lang      | science    | maths     |  
            --------------------------------------
            | int | ext |  int | ext | int | ext |
    ----------------------------------------------
     1      | 50 |  40 |   50  | 30  |  50 |  45 |      
     2      | 50 |  30 |   50  | 45  |  50 |  30 |
    ----------------------------------------------

The same logic, should also be able to compare some other group of xml's, they follow their own kind of xsd's

Consider other kind for ex:

<employee name="1" rollNo="1">  
    <appearance height="" weight=90 gender=""/>
    <department name="HR" role="" experience=""/>
</employee>

<employee name="1" rollNo="1">  
    <appearance height="" weight=90 gender=""/>
    <department name="HR" role="" experience=""/>
</employee>

Expected Comparison HTML:

Employee Comparison:

--------------------------------------------------------
        |        Appearance         |   Department      |
Roll No |-----------------------------------------------|
        | height | weight |  gender |   name | role     |
---------------------------------------------------------
1       |                                               |       
---------------------------------------------------------
2       |                                               |
---------------------------------------------------------

Is there any best/recommended/generic approach to achieve this? Tools? thrid-parties? API's? In terms of performance? maintenance?

Right now, to achieve this, what I have done is step1: append all xml under a single parent [ex: repeating student nodes under students] step2: Write customized xslt for each type of xsd family and digest against the concated xml results and make HTML out of it.

Tools: java - xsd's, xml parsers, xslt, HTML

As per my project req, I expect atleast 30 kind of xsd families, and the comparison framework should support all of them with generic impl.

Any recommendation would be really saving my days :)

Element type "settings" must be followed by either attribute specifications, ">" or "/>"

http://ift.tt/1dFf4uT"   xmlns="http://ift.tt/1dFf4uQ" xmlns:xsi="http://ift.tt/ra1lAU ">